1

When I tried with Cucumber latest version 4.7.1 i.e.,'io.cucumber', with Extent report 3.0 the report is not generated. I have tried with different versions in extent report but still the output is generated properly.

I have tried with different combo versions between Cucumber and Extent Report but still no output. Someone could shed the light over here to bring up the output.

Code:

/**
 * @Author: PriyadarsiniMuthuvel
 * @Created date: 19-08-2019
 * @Project Description: CucumberGradleProject
 **/


import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import managers.FileReaderManager;

import java.io.File;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/test/resources/SmokeSuite",
        glue= {"stepDef"},
      //  plugin = { "pretty","html:target/cucumber-reports"},
 //  plugin = { "com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html"},
    // plugin = { "com.vimalselvam.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html"},
      plugin = { "com.aventstack.extentreportscucumber.adapter.ExtentCucumberAdapter:target/cucumber-reports/report.html"},
        monochrome = true
)
public class testrunner {

    @AfterClass
    public static void writeExtentReport() {

        Reporter.loadXMLConfig(new File(FileReaderManager.getInstance().getConfigReader().getReportConfigPath()));
        Reporter.setSystemInfo("User Name", System.getProperty("user.name"));
        Reporter.setSystemInfo("Time Zone", System.getProperty("user.timezone"));
        Reporter.setSystemInfo("Machine", System.getProperty ("os.name"));
        Reporter.setSystemInfo("Java Version", System.getProperty ("java.version"));
    }
}

Console:

java.lang.NoClassDefFoundError: gherkin/formatter/Reporter at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at com.vimalselvam.cucumber.listener.Reporter.getCurrentScenario(Reporter.java:166) at com.vimalselvam.cucumber.listener.Reporter.assignAuthor(Reporter.java:158) at stepDef.Hooks.BeforeSteps(Hooks.java:39) 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 cucumber.runtime.Utils$1.call(Utils.java:26) at cucumber.runtime.Timeout.timeout(Timeout.java:16) at cucumber.runtime.Utils.invoke(Utils.java:20) at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:65) at cucumber.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:16) at cucumber.runner.TestStep.executeStep(TestStep.java:65) at cucumber.runner.TestStep.run(TestStep.java:50) at cucumber.runner.TestCase.run(TestCase.java:42) at cucumber.runner.Runner.runPickle(Runner.java:50) at io.cucumber.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:146) at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:68) at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:23) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at io.cucumber.junit.Cucumber.runChild(Cucumber.java:142) at io.cucumber.junit.Cucumber.runChild(Cucumber.java:65) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at io.cucumber.junit.Cucumber$RunCucumber.evaluate(Cucumber.java:172) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 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) Caused by: java.lang.ClassNotFoundException: gherkin.formatter.Reporter at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 52 more

Ashok kumar Ganesan
  • 818
  • 4
  • 16
  • 39
  • The below dependencies used for the extent reports for io.cucumber.4.7.1: // https://mvnrepository.com/artifact/com.aventstack/extentreports-cucumber4-adapter compile group: 'com.aventstack', name: 'extentreports-cucumber4-adapter', version: '1.0.7' // https://mvnrepository.com/artifact/com.aventstack/extentreports compile group: 'com.aventstack', name: 'extentreports', version: '3.0.2' – PriyadarsiniMuthuvel Aug 27 '19 at 13:12
  • Priya, what is your cucumber version and Gherkin version that you used/mentioned in **pom.xml**. – Ashok kumar Ganesan Aug 27 '19 at 15:14
  • Cucumber 4.7.1. I have separately tried with extent adapter and extent report. But its not workout for me. – PriyadarsiniMuthuvel Aug 27 '19 at 15:16
  • 1
    Remove the AfterClass method in runner if you are using the extent adapter. – Grasshopper Aug 27 '19 at 16:33
  • Hi @Grasshopper, Thanks for the info. I have tried with the help of below links,http://grasshopper.tech/824/. In that article you have mentioned to add the system path in the pom.xml. i.e., com.aventstack extentreports-cucumber4-adapter 1.0.8 system D:/extentreports-cucumber4-adapter.jar – PriyadarsiniMuthuvel Aug 28 '19 at 07:17
  • how can I implement the same thing in the gradle. I has been used like that, // https://mvnrepository.com/artifact/com.aventstack/extentreports-cucumber4-adapter compile group: 'C:/Users/MSTSYS0/Desktop/CucumberGradleProject/src/test/resources/config/extentreports-cucumber4-adapter.jar', name: 'extentreports-cucumber4-adapter', version: '1.0.8' Kindly help me in this regards.@Grasshopper – PriyadarsiniMuthuvel Aug 28 '19 at 07:24
  • @PriyadarsiniMuthuvel Refer to this post - https://stackoverflow.com/questions/20700053/how-to-add-local-jar-file-dependency-to-build-gradle-file. – Grasshopper Aug 28 '19 at 07:50
  • @PriyadarsiniMuthuvel To obtain the similar thing (system path) in Gradle. Try with adding the dependencies as follows: **dependencies { compile files("mention the path of your file") }** Keep the path as relative/dynamic rather than absolute. – Ashok kumar Ganesan Aug 29 '19 at 04:26
  • @AshokkumarGanesan. I have used the same thing but its not work out. testCompile(files("C:/Users/MSTSYS0/Desktop/CucumberGradleProject/src/test/resources/config/extentreports-cucumber4-adapter.jar")) – PriyadarsiniMuthuvel Aug 29 '19 at 05:05
  • @AshokkumarGanesan Thanks much for your help – PriyadarsiniMuthuvel Aug 29 '19 at 12:05

1 Answers1

2

The Extent report is not supported in Cucumber 4.7.1v. Due to that,we have to work with Extent Report Cucumber Adapter.

In Gradle add the following things Cucumber 4.7.1, Extent Report Cucumber Adapter 1.0.7

Gradle path for Cucumber 4.7.1

compile group: 'com.aventstack', name: 'extentreports-cucumber4-adapter', version: '1.0.7'

In addition to that, manually download the jar and add it to build.gradle as below.

 compile files("src/test/resources/config/extentreports-cucumber4-adapter.jar")

(We have to include both the versions 1.0.7 & 1.0.8 to make it work)

Ashok kumar Ganesan
  • 818
  • 4
  • 16
  • 39