TestNG Tutorials 12: How To Run Inner TestNG Class From TestNG.xml ?

Hello Folks,

We will see an interesting topic in this post.

We can create an inner TestNG class as well like any normal inner class in Java. An example is as below:

Let’s try to generate a testng.xml for this:

TestNG includes outer and inner class names default. That’s good. Happy.

Now run above testng.xml:

It is not able to find inner class. So it is throwing an exception stating can not find class in class path.

Solution: You need to take help of <package> tag here. When you use package name, it will include inner class also and run successfully.

Output:

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