I am learning selenium. I am trying to get into more and more automation.

Scenario (example): We are working in the agile. 2 weeks of sprint. We have a release after every 3 sprint. In our framework we have used hybrid approach (combination of data driven and POM). Every test class having 40 test cases and we have 20 test class, in total of 3 sprint there are 800 test cases out of which we need to select 500 test cases for regression.

Question: which method we should use

1: using testNG annotation groupBy to give a name as a regression and then create a testng.XML file (or regression.XML) and pass with the group. If yes then how to declare in our XML file?

2: is there any better approach?


Here is the Sample XML file code

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Sample Suite">
  <test name="testing">
        <include name="Regression"/>
       <class name="com.example.group.groupExamples" />

For more details checkout TestNG groups


You can declare the groups as

<include name="group1"></include>
<include name="group2"></include>

Then in the class file declare as

<class name="packagename.ClassName"/> 
<class name="packagename.ClassName" />

If you are passing any parameters then declare as

<parameter name="browser" value="chrome"></parameter>
<parameter name="url" value="https://localhost"></parameter>

you can go with BDD-cucumber .cucumber will provide you the custom tags by which you can easily divide your regression suite to multiple groups such as, @regression @sanity @high-level

Example suppose i am having 1000 test cases in my regression and i have to do the only high-level testing or sanity check so while writing the feature file you can give the custom tag to each scenario and your runner class will be:

@RunWith(Cucumber.class) @Cucumber.Options(format = {"pretty", "html:target/cucumber"}, tags = {"~@regression"}) public class runTest { }

Feature file:



The best method in my opinion will be to explore Groups in TestNG. You can mark the 500 Test Cases in Regressions as below :

@Test(priority=1, groups={"Regression"})
public void testCaseOne() {


In your testNG XML, include Group Tag to Run these testCases.

First mark all the Test Cases as per the need and then generate testNG XML by Right-Clicking on Project -> TestNG -> Convert to TestNG. The resultant XML should automatically have Groups tag to give you control over Test Execution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.