In this post, we are going to learn to generate customized testng.xml.
Generation of testng.xml depends upon how you create it. We will see some scenarios in this post.
Scenario 1: Generating testng.xml for an individual class.
We will take same example of previous post:
You need to select individual class and do right click on it and select “TestNg –> Convert to Testng”. In preview you can see only selected class is selected in testng.xml as shown below:
Class name is added with package name.
Scenario 2: Create a copy of “MyFirstTest.java” and paste in same package as “MySecondTest.java”. Repeat it and add third class name “MyThirdTest.java”.
Now select any two class names using( Use ctrl to select multiple) and do right click on it and select “TestNg –> Convert to Testng”. In preview you can see only selected classes are selected in testng.xml as shown below:
Scenario 3: In above scenarios, we have selected testng class. In this scenario, select package name “TestNGPrograms” and right click on it and select “TestNg –> Convert to Testng”. You can see all testng class of selected package will be included in testng.xml.
Scenario 4: Now create a new package under src and copy same classes of package “TestNGPrograms”. Do right click on Project name “TestNGProjects” and select “TestNg –> Convert to Testng”. You will see all testng classes from both the packages are included in testng.xml.
So the conclusion is that testng xml is generated for all testng classes which are in scope based on user selection in project hierarchy. Remember you can not select multiple project to generate testng xml.
More about TestNG in upcoming posts. Stay tuned.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
Author: Amod Mahajan
My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning