Answer
Cucumber HTML Reports with Masterthought Plugin
Why Masterthought?
The default Cucumber html plugin generates basic reports. The Masterthought (net.masterthought) plugin generates enterprise-grade reports with:
- ✓Dashboard with pass/fail charts
- ✓Feature-level breakdown
- ✓Scenario timeline
- ✓Expandable step details
- ✓Screenshot embedding
- ✓Trend tracking
Step 1: Generate JSON Output First
Java
@CucumberOptions(
plugin = {
"pretty",
"json:target/cucumber-reports/cucumber.json" // ← required input
}
)
public class TestRunner extends AbstractTestNGCucumberTests {}
Step 2: Add Maven Plugin
XML
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.8.1</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase> <!-- runs after test phase -->
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>AutomateQA-BDD</projectName>
<skip>false</skip>
<outputDirectory>target/cucumber-html-reports</outputDirectory>
<jsonFiles>
<param>target/cucumber-reports/cucumber.json</param>
<!-- multiple JSON files for parallel runs -->
<param>target/cucumber-reports/cucumber2.json</param>
</jsonFiles>
<!-- Optional: classify builds -->
<classifications>
<Branch>main</Branch>
<Environment>Staging</Environment>
<Browser>Chrome</Browser>
</classifications>
<mergeFeaturesById>true</mergeFeaturesById>
</configuration>
</execution>
</executions>
</plugin>
Run and View
Bash
# Run tests + generate report
mvn clean verify
# Report location
target/cucumber-html-reports/overview-features.html
Using Allure for Even Richer Reports
XML
<!-- pom.xml -->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber7-jvm</artifactId>
<version>2.25.0</version>
</dependency>
Java
@CucumberOptions(
plugin = {
"io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm",
"json:target/cucumber.json"
}
)
Bash
# Generate and serve Allure report
mvn allure:serve
Allure Annotations in Step Definitions
Java
import io.qameta.allure.Allure;
import io.qameta.allure.Step;
public class LoginSteps {
@Step("User navigates to login page")
@Given("the user is on the login page")
public void navigateToLogin() {
driver.get(baseUrl + "/login");
Allure.addAttachment("Page URL", driver.getCurrentUrl());
}
@Step("User enters credentials: {username}")
@When("the user enters username {string} and password {string}")
public void enterCredentials(String username, String password) {
loginPage.enterUsername(username);
loginPage.enterPassword(password);
}
}
Jenkins Integration
GROOVY
// Jenkinsfile
stage('Test') {
steps {
sh 'mvn clean verify'
}
post {
always {
cucumber(
fileIncludePattern: '**/cucumber.json',
jsonReportDirectory: 'target/cucumber-reports',
reportTitle: 'AutomateQA BDD Report'
)
}
}
}
