In real projects, you do not have one runner class. You have separate runners for smoke tests, regression tests, banking tests, shopping tests. Each runner filters by different tags and generates its own reports.
@CucumberOptions(
features = "src/test/resources/features",
glue = {"com.autopractice.stepdefinitions",
"com.autopractice.hooks"},
plugin = {
"pretty",
"html:target/cucumber-reports/smoke.html",
"json:target/cucumber-reports/smoke.json"
},
tags = "@smoke",
monochrome = true
)
public class SmokeRunner extends AbstractTestNGCucumberTests {
}@CucumberOptions(
features = "src/test/resources/features",
glue = {"com.autopractice.stepdefinitions",
"com.autopractice.hooks"},
plugin = {
"pretty",
"html:target/cucumber-reports/regression.html",
"json:target/cucumber-reports/regression.json"
},
tags = "@regression and not @wip",
monochrome = true
)
public class RegressionRunner extends AbstractTestNGCucumberTests {
@Override
@DataProvider(parallel = true)
public Object[][] scenarios() {
return super.scenarios();
}
}// Run only Banking features
@CucumberOptions(
features = "src/test/resources/features/banking",
glue = {"com.autopractice.stepdefinitions",
"com.autopractice.hooks"},
plugin = {"pretty",
"html:target/cucumber-reports/banking.html"},
monochrome = true
)
public class BankingRunner extends AbstractTestNGCucumberTests {
}<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="BDD Suite" parallel="classes" thread-count="2">
<test name="Smoke">
<classes>
<class name="com.autopractice.runner.SmokeRunner" />
</classes>
</test>
<test name="Regression">
<classes>
<class name="com.autopractice.runner.RegressionRunner" />
</classes>
</test>
</suite>In CI/CD, have your pipeline run SmokeRunner on every commit (fast, 2-5 minutes) and RegressionRunner nightly (full suite, 30+ minutes). Switch between them by changing which runner class Maven targets.
Key Point: Create separate runner classes for smoke, regression, and module tests. Use testng.xml to orchestrate them.