Unable to generate the extent-report

Felipe Luz

Using the plugin com.vimalselvam.cucumber.listener.ExtentCucumberFormatter (the only that worked for me), my report is generated but with several errors on the log of intellij

I've tried to generate the report with a scenario not defined (just for the speed). Using more than one plugin, as the plugin

These are the depencies I'm using:

<dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.5</version>
</dependency>
 <dependency>
            <groupId>com.vimalselvam</groupId>
            <artifactId>cucumber-extentsreport</artifactId>
            <version>3.1.1</version>
</dependency>
<dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>4.0.9</version>
</dependency>
<dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports-cucumber4-adapter</artifactId>
            <version>1.0.7</version>
</dependency>

@CucumberOptions(plugin = {"com.vimalselvam.cucumber.listener.ExtentCucumberFormatter:output/report.html")

@AfterClass
    public static void writeExtentReport() {
Reporter.loadXMLConfig(new File("path/extent-config.xml"));
}

The errors:

log4j:WARN No appenders could be found for logger (freemarker.cache).
log4j:WARN Please initialize the log4j system properly.


java.lang.NoSuchMethodError: com.aventstack.extentreports.reporter.ExtentHtmlReporter.loadXMLConfig(Ljava/io/File;)V

at com.vimalselvam.cucumber.listener.Reporter.loadXMLConfig(Reporter.java:66)
at test.runner.TestRunner.writeExtentReport(TestRunner.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)


java.lang.NullPointerException
    at com.vimalselvam.cucumber.listener.ExtentCucumberFormatter.result(ExtentCucumberFormatter.java:252)...
TheSociety

You are using vimal, avenstack and adapter dependencies all together in pom.xml which is not advisable and expected. One shall use vimal or avenstack or both together in specific use case or use adapter dependency only. Please follow below instructions.

Vimal Selvam Library: Below is the required maven dependency and a sample test to demonstrate how configuration set up is done.

Maven Dependency

<dependency>
    <groupId>com.vimalselvam</groupId>
    <artifactId>cucumber-extentsreport</artifactId>
    <version>3.1.1</version>
</dependency>


<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>4.0.9</version>
</dependency>

Please note that Java 8+ and adding the dependency of ExtentReport v3.1.1+ is mandatory.

Cucumber Runner File

 @RunWith(Cucumber.class)
    @CucumberOptions(
            features = {"src/test/resources/features"},
            glue = {"com.cucumber.stepdefinitions"},
            plugin = {"com.cucumber.listener.ExtentCucumberFormatter:output/report.html"}
            )
    public class RunCukesTest {
        @AfterClass
        public static void teardown() {
            Reporter.loadXMLConfig(new File("src/test/resources/extent-config.xml"));
            Reporter.setSystemInfo("user", System.getProperty("user.name"));
            Reporter.setSystemInfo("os", "Mac OSX");
            Reporter.setTestRunnerOutput("Sample test runner output message");
        }
    }

The above setup will generate the report in output directory with the name of report.html.

Please remove adapter dependency from pom.xml. We shall use vimal/avenstack or extent adapter but not all together.

Extent Adapter: Beauty is, you do not need to write any code any where to generate report this way except from setting adapter in runner below.

Maven Dependency

<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports-cucumber4-adapter</artifactId>
    <version>1.0.6</version>
</dependency>

Add the com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter plugin to the runner.

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"})
public class RunCukesTest {
    // ..
} 

Report Output Directory - ../Project Directory/test-output/HtmlReport

Additional Note: In future, we would request you to use Cucumber v>=4.0.0 as you are using pretty old dependency(v1.2.5) of Cucumber.

For doing so, you can add below set of cucumber minimal dependencies.

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.2.6</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.2.6</version>
    <scope>test</scope>
</dependency>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Unable to generate Extent Report in Selenium Java

How to generate report (Extent Report) in Specflow Project

Unable to generate extent report in cucumber. I am using cucumber version 4

How to generate extent report in karate framework?

Generate extent report using "ITestListener" or "IReporter" listeners

Unable to generate a report with SAP Crystal report

Unable to generate Extent reports (Version 3.1.3)in selenium with c#

Karate Extent Report integrtion

Extent Report 4 not creating report

Unable to generate allure report using testng and maven

Extent Report 3 Add Screenshot

Extent Report Issue Parallel testing

Extent report is not working in Cucumber 4.7.1

Extent report is not giving proper report on parallel execution

Unable to generate code coverage report of a gin-gonic server application

Jenkins unable to generate test report due to NoClassDefFoundError - ParseResultCallable

Unable to generate report using html screen shot in protractor

unable to generate HTML report using Webpack-bundle-analyser

Upgrade to AGP 4.2.0 ,unable to generate Jacoco code coverage report

Difference between Tests and Steps in testng extent report

How to capture all test cases in extent report?

Extent report logs for Test Steps is not working

Is Extent report version 5 now available or not?

Migrating from Extent Report 3.1.5 to 4.1.6 for Selenium

Is it possible to generate extent from VectorTiles source?

How to display test name under Extent Report instead of Method Name?

Extent Report Spark Disregards Line Feed (New Line)

How to Customise the Extent Report by removing unwanted graphs and Extra space

Generate JUnit Test report