top of page

Cucumber Extent Reporting

Updated: Jul 6, 2020

To implement cucumber extent reporting you need to follow the steps as mentioned below:

1. Download Java 8+ version.

2. Extent reports version 3.0.6+ is required, you need to add following dependency in pom.xml for maven project:

<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.7</version>
<scope>provided</scope>
</dependency>

If it is a java project ,download the jars from this url.


3. Add dependency for cucumber extent report:

<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.1</version>
</dependency>

4. Make sure maven-complier-plugin  AND maven-surefire-plugin are present in the pom.xml, otherwise add their dependencies as mentioned below:

<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<type>maven-plugin</type>
</dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>

5. Download extent-config.xml file from here & add it to “target” folder of your project.









6. Create a runner class & add the plugin in

@CucumberOptions as com.cucumber.listener.ExtentCucumberFormatter:output/report.html

followed by the report file as input parameter.


A sample example is shown below:

import org.junit.runner.RunWith;
import org.testng.annotations.AfterClass;
import com.cucumber.listener.Reporter;
import java.io.File;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(format = { "pretty", "json:target/json/output.json" },
 features = {"C:\\Users\\Adminindia\\workspace\\shaurya\\cookies\\src\\test.feature"},
 glue = {"step_definitions"}, tags = {"@tag1"},
 plugin = {"com.cucumber.listener.ExtentCucumberFormatter:output/report.html"})

public class testrunner {
	@AfterClass
	public static void teardown() {

		Reporter.loadXMLConfig(new File("target/extent-config.xml"));
		Reporter.setSystemInfo("user", System.getProperty("user.name"));
		Reporter.setSystemInfo("os", "Mac OSX");
		Reporter.setTestRunnerOutput("Sample test runner output message");
	}
}

The above setup will generate the report in output directory with the name of report.html


The report will be generated as shown below:


206 views0 comments

Comments


bottom of page