Cucumber Extent Report

Cucumber Extent Report 3.x.x with ExtentX

Update: A new patch has been released with additional feature to assign authors to scenario. Kindly update to v3.0.1. Refer documentation.

I’m happy to announce that now the Cucumber Extent Report comes with the support for configuring your ExtentX dashboard. And moreover, introducing ExtentProperties enum to help you to configure extent related settings.

If you are using a maven based project, you can directly add this library as a dependency:

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

Please note that Java 8+ and adding the dependency of ExtentReport v3.0.6+ is mandatory.

If you are not using maven, download the jar from here.

How to use?

Create a runner class and add the com.cucumber.listener.ExtentCucumberFormatter:output/report.html as a plugin followed by the report file as input (optional parameter).

A sample example is shown below:

package com.cucumber.runner;

import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.AfterClass;
import org.junit.runner.RunWith;

import java.io.File;

/**
 * A sample test to demonstrate
 */
@RunWith(Cucumber.class)
@CucumberOptions(
    features = {"src/test/resources/features"},
    glue = {"com.cucumber.stepdefinitions"},
    plugin = {"com.cucumber.listener.ExtentCucumberFormatter:output/report.html"}
)
public class RunCukesTest {
    @AfterClass
    public static void teardown() {
        Reporter.loadXMLConfig(new File("src/test/resources/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. There are 3 ways to configure the report location:

  • As shown above, pass the report file path along with com.cucumber.listener.ExtentCucumberFormatter:
  • If in case you want a dynamic location, you can leave the file path parameter empty while configuring the plugin. For example:
    plugin = {“com.cucumber.listener.ExtentCucumberFormatter:”}
    This will generate the report file in the location output/Run_/report.html.
  • You can also configure the report location by using ExtentProperties enum as follows. Leave the plugin configuration empty, and configure the report location in your @BeforeClass method:
    plugin = {"com.cucumber.listener.ExtentCucumberFormatter:"}
    ......
    ......
    @BeforeClass
    public static void setup() {
        ExtentProperties extentProperties = ExtentProperties.INSTANCE;
        extentProperties.setReportPath("output/myreport.html");
    }

The above example shows a JUnit runner. However, you can use the TestNG runner too. Refer more examples here.
Also make sure the loadXMLConfig, setSystemInfo and setTestRunnerOutput methods should be in your @AfterClass method.

Setting up ExtentX

The current release added a support for ExtentX. The results of your execution can be sent to ExtentX dashboard.

The ExtentX configurations can be set up using ExtentProperties enum as follows:

plugin = {"com.cucumber.listener.ExtentCucumberFormatter:"}
......
......
@BeforeClass
public static void setup() {
    ExtentProperties extentProperties = ExtentProperties.INSTANCE;
    extentProperties.setReportPath("output/myreport.html");
    extentProperties.setExtentXServerUrl("http://localhost:1337");
    extentProperties.setProjectName("MyProject");
}

You can either setup ExtentX in your local / remote machine using:
A docker approach – 2 minutes to setup
A plain vanilla approach

There are plenty of other configurations / features available. Kindly go through the documentation to understand in detail.

P.S: If you like this post, feel free to hit the Like button and share it.

6 Replies to “Cucumber Extent Report 3.x.x with ExtentX”

  1. Hi vimal , Thanks for your extraordinary contribution. I have successfully integrated extent x report in my project . Its awsome. I have a doubt . In the extent x report how to get the author details . The author details is not getting displayed. Anything i need to add in the runner . Thank you very much 🙂

    1. Hi Jayasathya, assigning author was not available. Now I’ve added the feature. Kindly update to 3.0.1 and refer the documentation on how to assign an author to the scenario. Hope this helps.

  2. Hi Vimal,
    I have an issue in the report.
    I have 3 features with 65 scenarios and about 280 steps.
    Aftrer run I have such situation:
    – all 3 features are failed (it is correct, because in each I have failed scenarios)
    – all 65 scenarios are failed as well (why?) (each feature have at least 1 failed scenario, but not all of them)
    – and over 260+ steps are passed.
    As you can see,

    So the question is: Why are all scenarios failed?

    Maybe I do something wrong?

    Thank you.
    Mike

    P.S. Version of Cucumber Extent Report 3.0.1,
    version of Extent reports 3.0.6

Leave a Reply