By Shivam Singh, founder of TesterRank · Updated September 2026
Reports are how you communicate test results to the team. Cucumber generates basic reports out of the box. For richer reports with charts and embedded screenshots, use the Masterthought cucumber-reporting library.
| Plugin | Output | Best For |
|---|---|---|
| pretty | Colored console output | Watching tests run locally |
| html:path/report.html | Basic HTML file | Quick local review |
| json:path/report.json | JSON data | Input for third-party tools |
| junit:path/report.xml | JUnit XML | Jenkins and CI/CD integrations |
| timeline:path/timeline | Timeline view | Visualizing parallel execution |
The Masterthought cucumber-reporting library generates beautiful HTML reports from your Cucumber JSON output. It shows feature-level stats, scenario breakdowns, embedded screenshots, and execution time.
<!-- Add to pom.xml -->
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>5.8.0</version>
</dependency>This class reads Cucumber's JSON results and builds the Masterthought HTML report.
import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.ReportBuilder;
import java.io.File;
import java.util.List;
public class ReportGenerator {
public static void generate() {
File outputDir = new File("target/cucumber-html-reports");
List<String> jsonFiles = List.of(
"target/cucumber-reports/report.json");
Configuration config = new Configuration(
outputDir, "AutoPractice BDD Tests");
config.setBuildNumber("1.0.0");
config.addClassifications("Browser", "Chrome 122");
config.addClassifications("Environment", "QA");
config.addClassifications("OS", "Windows 11");
new ReportBuilder(jsonFiles, config).generateReports();
}
}Call it once after all tests finish, so the report includes every scenario.
// Call report generation after all tests finish
public class TestRunner extends AbstractTestNGCucumberTests {
@AfterSuite
public void generateReport() {
ReportGenerator.generate();
System.out.println("Report: target/cucumber-html-reports/");
}
}Screenshots captured with scenario.attach() in the @After hook are automatically embedded in both built-in and Masterthought reports. When a test fails, you see the screenshot inline — no hunting for files.
@After
public void tearDown(Scenario scenario) {
WebDriver driver = driverThread.get();
if (scenario.isFailed() && driver != null) {
byte[] screenshot = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.BYTES);
// This embeds the screenshot in the HTML report
scenario.attach(screenshot, "image/png",
"Failure-" + scenario.getName());
}
if (driver != null) {
driver.quit();
driverThread.remove();
}
}Q: How do you generate reports in Cucumber?
A: Cucumber has built-in plugins: "pretty" for console output, "html" for basic HTML, "json" for JSON data, "junit" for XML. For richer reports, I use the Masterthought cucumber-reporting library — it takes the JSON output and generates detailed HTML reports with feature-level statistics, scenario pass/fail breakdown, embedded screenshots, execution time, and environment metadata. I configure the JSON plugin in @CucumberOptions and call the report generator in an @AfterSuite method. Screenshots are embedded using scenario.attach() in the @After hook.
Key Point: Built-in plugins for basic reports. Masterthought for rich HTML. scenario.attach() embeds screenshots.