范围报告在 Cucumber 4.7.1 中不起作用
Extent report is not working in Cucumber 4.7.1
当我尝试使用 Cucumber 最新版本 4.7.1 即,'io.cucumber',
使用 Extent report 3.0 不会生成报告。我在范围报告中尝试了不同的版本,但仍然正确生成了输出。
我在 Cucumber 和 Extent Report 之间尝试了不同的组合版本,但仍然没有输出。有人可以在这里照亮以调出输出。
代码:
/**
* @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"));
}
}
控制台:
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.access0(URLClassLoader.java:73) at
java.net.URLClassLoader.run(URLClassLoader.java:368) at
java.net.URLClassLoader.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.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.run(ParentRunner.java:290) at
org.junit.runners.ParentRunner.schedule(ParentRunner.java:71) at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at
org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58) at
org.junit.runners.ParentRunner.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.run(ParentRunner.java:290) at
org.junit.runners.ParentRunner.schedule(ParentRunner.java:71) at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at
org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58) at
org.junit.runners.ParentRunner.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
Cucumber 4.7.1v 不支持范围报告。因此,我们必须使用 Extent Report Cucumber Adapter。
在Gradle中添加以下内容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'
除此之外,手动下载 jar 并将其添加到 build.gradle,如下所示。
compile files("src/test/resources/config/extentreports-cucumber4-adapter.jar")
(我们必须同时包含版本 1.0.7 和 1.0.8 才能使其正常工作)
当我尝试使用 Cucumber 最新版本 4.7.1 即,'io.cucumber', 使用 Extent report 3.0 不会生成报告。我在范围报告中尝试了不同的版本,但仍然正确生成了输出。
我在 Cucumber 和 Extent Report 之间尝试了不同的组合版本,但仍然没有输出。有人可以在这里照亮以调出输出。
代码:
/**
* @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"));
}
}
控制台:
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.access0(URLClassLoader.java:73) at java.net.URLClassLoader.run(URLClassLoader.java:368) at java.net.URLClassLoader.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.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.run(ParentRunner.java:290) at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58) at org.junit.runners.ParentRunner.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.run(ParentRunner.java:290) at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58) at org.junit.runners.ParentRunner.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
Cucumber 4.7.1v 不支持范围报告。因此,我们必须使用 Extent Report Cucumber Adapter。
在Gradle中添加以下内容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'
除此之外,手动下载 jar 并将其添加到 build.gradle,如下所示。
compile files("src/test/resources/config/extentreports-cucumber4-adapter.jar")
(我们必须同时包含版本 1.0.7 和 1.0.8 才能使其正常工作)