By Shivam Singh, founder of TesterRank · Updated September 2026
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.
A runner class tells Cucumber which features and tags to run. This one runs only the @smoke scenarios.
@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 {
}The regression runner runs everything and turns on parallel execution to save time.
@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();
}
}You can also have a runner for one area of the app, such as banking only.
// 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 {
}testng.xml then picks which runners to use, just like normal TestNG classes.
<?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.