Cucumber provides several ways to generate test execution reports, which are helpful for analyzing test results, sharing with teams, and debugging failures.
Basic Report with
pretty
PluginThis prints a detailed text output in the console (in readable format).
@CucumberOptions(
plugin = {"pretty"}
)
Generate a basic HTML report:
@CucumberOptions(
plugin = {"pretty", "html:target/cucumber-reports.html"}
)
This creates a report at:
target/cucumber-reports.html
JSON Report
Use this when you want to integrate with tools like Extent Reports, Allure, or Jenkins:
@CucumberOptions(
plugin = {"json:target/cucumber.json"}
)
Output:
cucumber.json
file that can be parsed by reporting tools.JUnit XML Report
Useful for CI tools (like Jenkins) to parse test results:
@CucumberOptions(
plugin = {"junit:target/cucumber-results.xml"}
)
@CucumberOptions(
features = "src/test/java/features",
glue = "stepDefinitions",
plugin = {
"pretty",
"html:target/cucumber-reports.html",
"json:target/cucumber.json",
"junit:target/cucumber-results.xml",
"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"
},
monochrome = true,
tags = "@SmokeTest"
)
public class TestNGRunner extends AbstractTestNGCucumberTests {
}