Introduction to Extent Reports:
Extent Report is an open-source reporting library used in Selenium and Cucumber frameworks for generating HTML reports for test executions.
It provides a comprehensive and interactive report that displays the test execution results in an organized manner with charts and graphs, which makes it easier for users to analyze and understand the results.
Extent Report provides the following features:
- Customizable reports: Users can customize the look and feel of the reports based on their requirements.
- Rich visualization: Reports include detailed charts and graphs that help users to understand the test execution results easily.
- Real-time reporting: The report gets updated in real-time as the tests run, making it easy to track the progress of the test execution.
- Easy integration: Extent Reports can be easily integrated with other testing frameworks like Selenium and Cucumber.
Here is an example of how to use Extent Report in a Cucumber framework:
1. Add the Extent Report and Cucumber7 Adapter dependency to the pom.xml file like the below:
<dependency> <groupId>tech.grasshopper</groupId> <artifactId>extentreports-cucumber7-adapter</artifactId> <version>1.7.0</version> </dependency> <dependency> <groupId>com.aventstack</groupId> <artifactId>extentreports</artifactId> <version>5.0.9</version> </dependency>
2. Create an ExtentReport.properties file and Enter the below data in the property file:
extent.reporter.spark.start=true extent.reporter.spark.out=MyExtentReport.html extent.reporter.spark.config=src/test/resources/Extent-config.xml basefolder.name=Extent/ExtentReport basefolder.datetimepattern=d-MMM-YY HH-mm-ss extent.reporter.spark.vieworder=dashboard,test,category,exception,author,device,log systeminfo.OS=Windows10 systeminfo.Engineer= yourname
3. Add the Extent Report in Cucumber Runner Class in the plugin field like below:
package runner;  import org.junit.runner.RunWith;  import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions; import util.Hooks;  @RunWith(Cucumber.class) @CucumberOptions(features={"src//test//java//featurefiles"} ,glue={"stepdefinitioncode"} ,plugin={"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"} ,tags= "@mobile" ,monochrome=true  )  public class TestRunner{      } Â
Run the Cucumber tests, and the Extent Report will be generated in the specified location as per the location mentioned in the ExtentReport property file.
Conclusion:Â Extent Report is an excellent tool for generating interactive reports that help testers to analyze test results quickly and efficiently. Its customizable reporting features and easy integration with other testing frameworks make it an ideal choice for test automation.
Post a Comment