TestNG Tutorials 9: Internal Logic Of Generation Of TestNG.xml

Hello Folks,

In this post, we will learn logic behind generation of testng.xml.

When we select a class or package or project and chose to generate a testng.xml, it includes only those class names which has at least one @Test annotated method. It will not consider a class which has no @Test annotated method.

Suppose we create a class without @Test method as below:

When we try to generate a testng.xml for this, it will look like as:

It will be an empty test i.e. a test without any class.

It will not even consider if it has other TestNG annotation like @BeforeClass or @BeforeSuite etc in a class. TestNG is a testing framework and if there is nothing to test, it will simply ignore that class. That is the reason, any validation or verification must be part of @Test annotated method only.

A class with TestNG annotated method other than @Test method:

When we generate a testng.xml for this, it will look like as:

It will be an empty test i.e. a test without any class.

Conclusion: So testng.xml will include only those classes which has at least one @Test annotated method in it.

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.
#ThanksForReading
#HappySelenium

3 thoughts on “TestNG Tutorials 9: Internal Logic Of Generation Of TestNG.xml

Leave a Reply

Your email address will not be published. Required fields are marked *