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

TestNGFrameworkJava Programming

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 <groups > 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.

raja
Published on 11-Jun-2020 16:11:02
Advertisements