Skip to content

Selcukes Extent Report

Ramesh Babu Prudhvi edited this page Mar 30, 2023 · 10 revisions

How to integrate Selcukes Extent Report

  • Add following Maven dependencies to pom.xml
<dependency>
    <groupId>io.github.selcukes</groupId>
    <artifactId>selcukes-extent-reports</artifactId>
    <version>LATEST<version>
    <scope>provided</scope>
</dependency>
  • Create extent.properties file in src/test/resources
extent.reporter.spark.start=true
extent.reporter.spark.out=target/extent-reports/Sample.html
systeminfo.Author=Ramesh
selcukes.reports.timestamp=true
extent.reporter.spark.vieworder=dashboard,test,category,exception,author,device,log
  • Add Selcukes Extent Report plugin to cucumber runner
@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 file as follows
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());
	}
}

The above Hooks class will take care of extent report integration

Note: Use Selcukes Logger to attach custom info logs to extent report

If you are not using selcukes webdriver-binaries dependencyin your project then add below depedecy to

<dependency>
    <groupId>io.github.selcukes</groupId>
    <artifactId>selcukes-commons</artifactId>
    <version>LATEST<version>
    <scope>provided</scope>
</dependency>
Clone this wiki locally