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.


Testng xml files with groups.

<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE suite SYSTEM "" >
<suite name = "Tutorialspoint Test">
   <test name = "Regression Cycle 1">
            <include name = "Smoke"/>
         <class name = "TestParam" />

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.


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.