Cucumber_Selenium_Reporting
Cucumber_Selenium_Reporting
========================================
|-Reporting is essential in Cucumber and Selenium automation to track test
execution, failures, and success rates.
|-Cucumber provides built-in reports with the pretty, json, and html formats.
@CucumberOptions(
features = "src/test/resources/features",
glue = "stepDefinitions",
plugin = {
"pretty",
"html:target/cucumber-reports.html",
"json:target/cucumber.json"
}
)
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extentreports-cucumber7-adapter</artifactId>
<version>1.7.0</version>
</dependency>
@CucumberOptions(
features = "src/test/resources/features",
glue = "stepDefinitions",
plugin = {
"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"
}
)
📌 Step 3: Configure Extent Report (extent-config.xml) Create an extent-config.xml
file in src/test/resources/:
<extentreports>
<configuration>
<theme>dark</theme>
<encoding>UTF-8</encoding>
<reportName>Cucumber Extent Report</reportName>
<documentTitle>Test Automation Report</documentTitle>
</configuration>
</extentreports>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber7-jvm</artifactId>
<version>2.21.0</version>
</dependency>
test-output/index.html
Summary
Reporting Tool Feature File Location
Cucumber HTML Report Default, simple HTML target/cucumber-
reports.html
Extent Reports Advanced, detailed UI, graphs target/extent-
report/index.html
Allure Reports Interactive UI, test trends
allure-report/index.html
TestNG Reports Basic HTML for Selenium-TestNG test-
output/index.html
Cucumber_Reporting_Project/
|-src/main/java
|-src/main/resources
|-src/test/java
|-com.automation.stepDefinitions
|-LoginStep.java
|-com.automation.runner
|-TestNGRunner.java
|-src/test/resources
|-Features
|-Login.feature
|-extent-config.xml
<!-- https://mvnrepository.com/artifact/tech.grasshopper/extentreports-cucumber7-
adapter -->
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extentreports-cucumber7-adapter</artifactId>
<version>1.13.0</version>
</dependency>
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
<extentreports>
<configuration>
<theme>dark</theme>
<encoding>UTF-8</encoding>
<protocol>https</protocol>
<reportName>Cucumber Extent Report</reportName>
<documentTitle>Test Automation Report</documentTitle>
<reportHeadline>Cucumber Extent Report Example</reportHeadline>
</configuration>
</extentreports>
package com.ecommerce.runner;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
@CucumberOptions(
features = "src/test/resources/Features/Login.feature", // Path to
feature files
glue = "com.ecommerce.stepDefinitions" , // Step definitions package
plugin = {
"pretty",
"html:target/Cucumber-Reports/cucumber_report.html",
"json:target/Cucumber-Reports/cucumber_report.json",
"junit:target/Cucumber-Reports/cucumber_report.xml",
"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:target/
Cucumber-Reports" // Extent Report Adapter
}
)
public class TestNGRunner extends AbstractTestNGCucumberTests{