Skip to main content

Extent Reports

Selcukes Extent Reports is used to generate Extent reports for Cucumber JVM.

Features

  1. Generates Emailable extent report
  2. Full page screenshots attached to report as base64 format
  3. Supports to add JUL based info logs to report

Setup

Selcukes Extent Reports is primarily used as a Java dependency . We typically use a build tool (such as Maven or Gradle) to resolve the Selcukes Extent Reports dependency.


<dependency>
<groupId>io.github.selcukes</groupId>
<artifactId>selcukes-extent-reports</artifactId>
<version>${selcukes.version}</version>
</dependency>
note

Selcukes Extent Reports is a transitive Dependency of selcukes-reports.If you are using selcukes-reports, then ignore adding this dependency explicitly.

warning

If you are using selcukes-testng then set emailReport as true in selcukes.yaml file. No other configurations required

Usage

Create an extent.properties file in the src/test/resources folder with the following properties:

extent.reporter.spark.start=true
extent.reporter.spark.out=target/extent-reports/Sample.html
systeminfo.Author=Ramesh
selcukes.reports.timestamp=false
selcukes.reports.thumbnail=false

Add Selcukes Extent Reports plugin to the cucumber runner by adding io.github.selcukes.extent.report.SelcukesExtentAdapter to the plugin option in the @CucumberOptions annotation:

@CucumberOptions(tags = "@tag1", plugin = {
"io.github.selcukes.extent.report.SelcukesExtentAdapter",
"html:target/cucumber-reports/cucumber.html", "json:target/cucumber-reports/cucumber.json"

})

Update Cucumber Hooks

package io.github.selcukes.example.cucumber.steps;

import io.cucumber.java.After;
import io.cucumber.java.AfterAll;
import io.cucumber.java.AfterStep;
import io.cucumber.java.Before;
import io.cucumber.java.BeforeAll;
import io.cucumber.java.BeforeStep;
import io.cucumber.java.Scenario;
import io.github.selcukes.example.cucumber.utils.TestContext;
import io.github.selcukes.excel.ScenarioContext;
import io.github.selcukes.extent.report.Reporter;
import lombok.CustomLog;
import org.openqa.selenium.WebDriver;

@CustomLog
public class CucumberHooks {
WebDriver driver;

public CucumberHooks(TestContext driverManager) {
driver = driverManager.getDriver();
}

@BeforeAll
public static void beforeAll() {
logger.info(() -> "Before All ...");
}

@AfterAll
public static void afterAll() {
logger.info(() -> "After All ...");
}

@Before
public void beforeTest(Scenario scenario) {
ScenarioContext.setTestName(scenario);
Reporter.getReporter().initSnapshot(driver);
logger.info(() -> "Starting Scenario .." + scenario.getName());
}

@BeforeStep
public void beforeStep(Scenario scenario) {
logger.info(() -> "Before Step");
}

@AfterStep
public void afterStep(Scenario scenario) {
logger.info(() -> "After Step");

try {
Reporter.getReporter().attachVisiblePageScreenshot();
} catch (Exception ignored) {
}
}

@After
public void afterTest(Scenario scenario) {
ScenarioContext.removeTestName();
logger.info(() -> "Completed Scenario .." + scenario.getName());
}
}
note

Use Selcukes Logger to attach custom info logs to extent report

That's it! With these steps, Selcukes Extent Reports plugin is integrated with Cucumber and will generate reports in the specified output folder.

Subscribe for product updates

By subscribing, you agree with Selcukes’s Terms of Service and Privacy Policy.