NoClassDefFoundError:com / aventstack / extentreports / reporter / ExtentHtmlReporter

时间:2019-03-09 17:29:47

标签: cucumber cucumber-jvm extentreports

我正在尝试使用^2.6.0mavenCucumber项目中获取报告。我正在使用 java 8 。这是我的依赖项:

ExtentReport

然后我使用下面的Runner类来运行我的所有<dependencies> <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.4.0</version> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java --> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>1.2.5</version> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit --> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> <version>1.2.5</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.vimalselvam/cucumber-extentsreport --> <dependency> <groupId>com.vimalselvam</groupId> <artifactId>cucumber-extentsreport</artifactId> <version>3.1.1</version> </dependency> </dependencies> 文件:

*.feature

但是当我运行测试运行程序时,它抱怨:

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
        features            = {"src/test/resources/features" }, 
        monochrome          = true,
        plugin              = {"com.vimalselvam.cucumber.listener.ExtentCucumberFormatter:output/report.html"},
        glue                = {"stepDefinitions"}
        )
public class TestRunnerJUnit {


}

更新:

当我添加以下依赖项时:

cucumber.runtime.CucumberException: java.lang.NoClassDefFoundError: com/aventstack/extentreports/reporter/ExtentHtmlReporter
    at cucumber.runtime.formatter.PluginFactory.instantiate(PluginFactory.java:114)
    at cucumber.runtime.formatter.PluginFactory.create(PluginFactory.java:87)
    at cucumber.runtime.RuntimeOptions.getPlugins(RuntimeOptions.java:245)
    at cucumber.runtime.RuntimeOptions$1.invoke(RuntimeOptions.java:291)
    at com.sun.proxy.$Proxy11.done(Unknown Source)
    at cucumber.runtime.junit.JUnitReporter.done(JUnitReporter.java:227)
    at cucumber.api.junit.Cucumber.run(Cucumber.java:101)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.NoClassDefFoundError: com/aventstack/extentreports/reporter/ExtentHtmlReporter
    at com.vimalselvam.cucumber.listener.ExtentCucumberFormatter.setExtentHtmlReport(ExtentCucumberFormatter.java:55)
    at com.vimalselvam.cucumber.listener.ExtentCucumberFormatter.<init>(ExtentCucumberFormatter.java:38)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at cucumber.runtime.formatter.PluginFactory.instantiate(PluginFactory.java:107)
    ... 12 more

我收到此新错误:

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

3 个答案:

答案 0 :(得分:2)

尝试替换这个

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

有了这个

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

组件“cucumber-extentsreport”和“extentreports”是不同的东西。 我遇到了同样的问题并通过使用“extentreports”版本 3.0.7 和“cucumber-extentsreport”版本 3.1.1 解决了 祝你好运!

答案 1 :(得分:0)

我得到了答案。 一切都很好,但是我需要在Feature文件的*.feature中添加一个值。 因此,在这里您可以看到 Feature 关键字应该存在,并且其前面的 恰好 应该是文本。如果您在下一行写文字,则会遇到错误。

Feature: Check Welcome-message
  As a user, I should find a welcome-message in my mailbox, and my age in my profile.

答案 2 :(得分:0)

我得到了答案。一切都很好,但是我需要在* .feature文件中为Feature添加一个值。因此,在这里您可以看到Feature关键字应该存在,并且在它前面应该是文本。如果将文本写在下一行,则会遇到错误。 :-是的,它对我也有用