How can a particular group of test cases get executed in TestNG?

We can run a particular set of test cases by including a group of test cases in the execution.

Example

Testng xml files with groups.

<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name = "Tutorialspoint Test">
   <test name = "Regression Cycle 1">
      <groups>
         <run>
            <include name = "Smoke"/>
         </run>
      </groups>
      <classes>
         <class name = "TestParam" />
      </classes>
   </test>
</suite>

To run a group of test cases from the set of test cases, we have to define in the testng xml file. Here the testNG xml contains group Smoke to be included in execution.

Example

@Test(groups={"Smoke"})
public void Payment(){
   System.out.println(“Payment is successful”);
}

In the Java class file only the test method with group as Smoke will be run out of the entire regression suite.

Updated on: 2020-06-11T12:41:02+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements