Skip to main content

Cucumber Extent Report using Cucumber 4 Adapter

Most of the companies use JUNIT with Cucumber. Integrating Extent report with TestNG is quite easy and straight forward but if you are integrating with JUNIT you will find yourself in trouble because JUNIT has limited annotation then TestNG. There are several custom solution but this adapter one is quite easy. To integrate Cucumber report using extent adapter follow below steps:

Note: This is for cucumber version 4 only. For cucumber 5 there is different solution.

Step 1: Add following dependency in pom.xml. 

<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports-cucumber4-adapter -->
<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports-cucumber4-adapter</artifactId>
    <version>1.0.12</version>
</dependency>

Step 2: Add following code inside TestRunner @CucumberOptions

plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:", "json:target/cucumber-report.json"}

Step 3: Add extent.properties file in folder src/test/resources

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

extent.reporter.avent.config=
extent.reporter.bdd.config=
extent.reporter.cards.config=
extent.reporter.email.config=
extent.reporter.html.config=
extent.reporter.klov.config=
extent.reporter.logger.config=
extent.reporter.tabular.config=

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/
screesnshot.dir=test-output/
screenshot.rel.path=../

That's all you can see the report in test-output folder you specified in extent.properties file.

Submitted by tgoswami on August 30, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.