Skip to main content

Cucumber TestNG Extent Report using Adapter

The Extent adapter which we have used for JUnit also exist for TestNG. You can generate extent report using TestNG listeners provided by Avent Stack or the plugin option by Grass Shopper. In this article we will do it using Avent Stack TestNG listener.

Here are the steps:

Step 1: Add following dependency to your pom.xml. You can check the latest one from here

<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports-testng-adapter</artifactId>
    <version>1.2.2</version>
</dependency>

Step 2: Add Extent ITestListener to your Runner class or to your TestNG.xml file

Runner Class

@Listeners({ExtentITestListenerClassAdapter.class})
public class RunCucumberTest extends AbstractTestNGCucumberTests 
{	

}

TestNG.xml

<suite name="Regression" parallel="none">
    <listeners>
        <listener class-name="com.aventstack.extentreports.testng.listener.ExtentITestListenerClassAdapter"></listener>
    </listeners>
     <test name="MyTest">
        <classes>
            <class name="com.pb.ctest.helper.RunCucumberTest" />
        </classes>
    </test>
</suite>

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

extent.reporter.spark.start=true
extent.reporter.spark.out=test-output/SparkReport/Spark.html

Step 4: Execute your runner class and check the output in given output folder

cucumber testng generate extent report

cucumber testng extent report generation

Submitted by tgoswami on January 23, 2022

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.