Getting Started

extentreports-cucumber4-adapter does all the heavy-lifting for you and can output information. Continue reading for more details.


Download

Start using the Cucumber4 adapter for Extent Framework by adding the dependency below.

Maven
<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports-cucumber4-adapter</artifactId>
    <version>${version}</version>
</dependency>

If you are using the professional version and would like to add the extentreports dependency from systemPath:

<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports-cucumber4-adapter</artifactId>
    <version>${version}</version>
</dependency>
<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>${version}</version>
    <scope>system</scope>
    <systemPath>/usr/extentreports-${version}.jar</systemPath>
</dependency>

If the above does not work, you can exclude the extentreports dependency from the adapter and explicitly add the depedency from systemPath:

<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports-cucumber4-adapter</artifactId>
    <version>${version}</version>
    <exclusions>
        <exclusion>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>${version}</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>
<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>${version}</version>
    <scope>system</scope>
    <systemPath>/usr/extentreports-${version}.jar</systemPath>
</dependency>
Gradle
dependencies {
    compile "com.aventstack:extentreports-cucumber4-adapter:${version}"
}
GitHub

extentreports-cucumber4-adapter


Usage

To begin using the adapter, add the com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter plugin to the runner.

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"})
public class RunCukesTest {
	// ..
}

Adding Reporters

Reporters can be added using an external properties file or System.setProperty().


Properties

The Extent-TestNG listener looks for the following file in your classpath:

  1. extent.properties

The properties files have 3 core components where ${name} is the name of the reporter (avent, bdd, logger, email etc.):

  • extent.reporter.${name}.start: [true/false] used to indicate the listener whether the reporter will be used
  • extent.reporter.${name}.config: [path of the config file] path of the reporter configuration.xml (Note: Klov uses a properties configuration). Reporter's XML configuration can be found in the reporter's docs under Configuration/XML.
  • extent.reporter.${name}.out: [output path] path where the report will be stored (Note: Klov does not use this key as no files are written to disk)

Initialization Properties

Below are the comprehensive properties to intialize reporters:

#extent.properties
extent.reporter.avent.start=true
extent.reporter.bdd.start=true
extent.reporter.cards.start=true
extent.reporter.email.start=true
extent.reporter.html.start=true
extent.reporter.klov.start=true
extent.reporter.logger.start=true
extent.reporter.tabular.start=true

extent.reporter.avent.config=avent-config.xml
extent.reporter.bdd.config=bdd-config.xml
extent.reporter.cards.config=cards-config.xml
extent.reporter.html.config=html-config.xml
extent.reporter.klov.config=klov.properties
extent.reporter.logger.config=logger-config.xml
extent.reporter.tabular.config=tabular-config.xml

extent.reporter.avent.out=test-output/AventReport/
extent.reporter.bdd.out=test-output/BddReport/
extent.reporter.cards.out=test-output/CardsReport/
extent.reporter.email.out=test-output/EmailReport/ExtentEmail.html
extent.reporter.html.out=test-output/HtmlReport/ExtentHtml.html
extent.reporter.logger.out=test-output/LoggerReport/
extent.reporter.tabular.out=test-output/TabularReport/

If you use only the Avent reporter, your property file would now look like:

#extent.properties
extent.reporter.avent.start=true
extent.reporter.avent.config=avent-config.xml
extent.reporter.avent.out=test-output/AventReport/

If you use Avent with Klov, your property file would now look like:

#extent.properties
extent.reporter.avent.start=true
extent.reporter.avent.config=avent-config.xml
extent.reporter.avent.out=test-output/AventReport/

extent.reporter.klov.start=true
extent.reporter.klov.config=klov.properties

System.setProperty()

It is possible to start reporters, provide configuration and output values through the use of System.setProperty("k", "v");. The keys as described in Initialization Properties section define the context which can be used with System.setProperty also.

If you are using System.setProperty(), make sure extent.properties is not in your classpath. These properties file are loaded by default causing configuration clashes with the supplied System settings.

public class SomeTestClass extends SomeBaseClass {

    static {
        System.setProperty("extent.reporter.avent.start", "true");
        System.setProperty("extent.reporter.avent.config", "avent-config.xml");
        System.setProperty("extent.reporter.avent.out", "test-output/AventReport/");
		
		System.setProperty("extent.reporter.klov.start", "true");
		System.setProperty("extent.reporter.klov.config", "klov.properties");
    }
    
    // .. tests
    
}

or directly in your BaseClass:

public abstract class SomeBaseClass {

    static {
        System.setProperty("extent.reporter.avent.start", "true");
        System.setProperty("extent.reporter.avent.config", "avent-config.xml");
        System.setProperty("extent.reporter.avent.out", "test-output/AventReport/");
		
		System.setProperty("extent.reporter.klov.start", "true");
		System.setProperty("extent.reporter.klov.config", "klov.properties");
    }
    
	// .. some code
}

Changelog


Version 4.0.0

Released on September 30, 2018

Initial