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

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 4+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went throw 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