1

I am trying to migrate my Cucumber automation project from cucumber (info.cukes ) to cucumber (io.cucumber)

During this process, i having trouble with migrating extend reports. Could you please help me with what I am missing?

dependency:

    <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.2.6</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>4.2.6</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>4.2.6</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-html -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-html</artifactId>
            <version>0.2.7</version>
        </dependency>
<dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.26-incubating</version>
        </dependency>


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

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

Runner class:

package CucumberWithAfterStep.AfterStepPOC;
import java.io.File;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features", glue = { "testSteps" }, plugin = { "pretty",
                                "html:target/cucumber", "json:target/cucumber.json" , "com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html" },
                                monochrome = true, 
                                tags = {"@WAC003 "}, dryRun = false)

public class MainRunnerTest {

 @AfterClass
 public static void writeExtentReport() {
     Reporter.loadXMLConfig(new File(FileReaderManager.getInstance().getConfigReader().getReportConfigPath()));
    }
 }

Error:

cucumber.runtime.CucumberException: Couldn't load plugin class: com.cucumber.listener.ExtentCucumberFormatter. It does not implement

cucumber.api.Plugin at cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:176) at cucumber.runtime.formatter.PluginFactory.pluginClass(PluginFactory.java:163) at cucumber.runtime.formatter.PluginFactory.getPluginClass(PluginFactory.java:220) at cucumber.runtime.formatter.PluginFactory.isStepDefinitionReporterName(PluginFactory.java:203) at cucumber.runtime.RuntimeOptions$ParsedPluginData.addPluginName(RuntimeOptions.java:386) at cucumber.runtime.RuntimeOptions.parse(RuntimeOptions.java:165) at cucumber.runtime.RuntimeOptions.(RuntimeOptions.java:108)

AleT
  • 90
  • 7
Anil Kumar P
  • 53
  • 1
  • 9
  • 1
    For Cucumber 4 use this - http://extentreports.com/docs/versions/4/java/cucumber4.html – Grasshopper Apr 19 '19 at 16:36
  • @Grasshopper, I've used Cucumber 4 with dependency which you suggested and still facing the issue. "cucumber.runtime.CucumberException: Couldn't load plugin class: com.cucumber.listener.ExtentCucumberFormatter" – Anil Kumar P Apr 19 '19 at 17:52
  • 1
    Look at the usage again. you need to add com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter to the plugin. Remove the one u have now. – Grasshopper Apr 19 '19 at 18:45
  • If you have any doubt for implementing V4.0.0, please refer to https://stackoverflow.com/questions/55760140/parallel-test-run-with-cucumber/55770301#55770301 – TheSociety Apr 20 '19 at 04:38

2 Answers2

1

There are 2 ways of implementing extent report in Cucumber

1. Using Cucumber-JVM 4 adapter for Extent Framework(extentreports-cucumber4-adapter) & below are the steps to implement -

Add adapter dependency under POM.XML

<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

2. Adding aventstack dependency under POM.XML

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

In this workflow, Do not Add the com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter plugin to the runner.

TheSociety
  • 1,936
  • 2
  • 8
  • 20
1

I had the same issue. you can use the following combination of dependencies, Cucumber-core 4.2.0 Cucumber-java 4.2.0 Cucumber-junit 4.2.0 extentreports-cucumber4-adapter 1.0.7

Please note Cucumber-extntsreport which is developed by vimalselvam is not supporting cucumber version 4. Because cucumber 4 is using event based reporting, not the formatter. so remove this dependency. cucumber-extentsreport 3.0.2

Sureshmani Kalirajan
  • 1,938
  • 2
  • 9
  • 18
  • I was already using that version of the adapter, downgraded my cucumber dependencies to match yours, but I'm still getting a message "NoClassDefFoundError: gherkin/GherkinDialectProvider. I've tried various version of Gherkin in my pom.xml too, but my development machine is kind of wonky - I'm having to manually download and add libraries - the maven is sometimes downloading sometimes not. I've been racking my brain trying to get any kind of Cucumber reports working on my laptop (company laptop/network) even though I can get it all working with other laptop. – Bill Hileman May 17 '19 at 17:54