Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

TestNG Tutorials 65 : Dry Run Feature in TestNG

Posted on 02/19/2025 By admin

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:-

package TestMethods1;

import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class TestClass1 {
        
        
        @BeforeTest
        public void BeforeTestMethod()
        {
                System.out.println("BeforeTest");
        }
        
        
        @Test 
        public void TestClass1Method1()
        {
                System.out.println("TestClass1 Method1");
                
                
        }
        
        
        @Test
        public void TestClass1Method2()
        {
                System.out.println("TestClass1 Method2");
                
                
        }

}

Testclass2.java:-

package TestMethods1;

import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class TestClass2 {
        
        @BeforeTest
        public void BeforeTestMethod1()
        {
                System.out.println("BeforeTest1");
        }
        
        @Test
        public void TestClass2Method1()
        {
                System.out.println("TestClass2 Method1");
                
                
        }
        
        
        @Test
        public void TestClass2Method2()
        {
                System.out.println("Test Class2 Method2");
                
                
        }

}

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:-

package TestMethods1;

import org.testng.annotations.BeforeTest;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

public class TestClass1 extends TestBase{
        
        
        @BeforeTest
        public void BeforeTestMethod()
        {
                System.out.println("BeforeTest");
        }
        
        
        @Test @Ignore
        public void TestClass1Method1()
        {
                System.out.println("TestClass1 Method1");
                System.out.println(name);
                
        }
        
        
        @Test
        public void TestClass1Method2()
        {
                System.out.println("TestClass1 Method2");
                System.out.println(name);
                
        }

}

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

Uncategorized

Post navigation

Previous Post: Interview Experience at Harman Connected Services Bangalore for Manual & Automation Testing Profile – Aug-2019
Next Post: Protractor Tutorial 8 – NPM – Updating Global and Local Package

Related Posts

image – Make Selenium Easy Uncategorized
REST Assured Tutorial 14 –RequestSpecification – How the request will look like Uncategorized
singleHtml – Make Selenium Easy Uncategorized
MultiSelectOutput – Make Selenium Easy Uncategorized
Hierarchy of Selenium Classes and Interfaces – Make Selenium Easy Uncategorized
How Much Java Required For Selenium? | Make Selenium Easy Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark