As a part of TestNG Tutorials, in this post we will see a new feature provided by TestNG called Dry run of test methods.

You may heard of the term “Dry Run” in Cucumber. If you want to check that every step in a feature file has its corresponding step definitions, we can run feature file with dryRun cucumber option.

Similar kind of feature is provided by TestNG now. If you want to see a list of the test methods that would be invoked on run without running them actually, you can use dry run feature. Remember it will give only @Test annotated methods not configuration methods like @BeforeXXXX and @AfterXXXX.

We will see an example so that it will be more clear to you:-

Testclass1.java:-

Testclass2.java:-

Testng.xml:-

To run in dry run mode, we need to pass a JVM argument as -Dtestng.mode.dryrun=true

Go to Run configuration and select your project and pass argument as shown below:-

Now run and see output. You will see methods are called but was not run.

Let’s disable a test method and rerun:-

You can play around this feature with include and exclude groups. This feature is helpful to know if all your intended test methods will run or not.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappyLearning

You can find all Selenium related post here.
You can find all API manual and automation related posts here.
You can find frequently asked Java Programs here.



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

Leave a Reply