集成cumul.adapter.ExtentCucumberAdapter

时间:2019-02-16 07:56:03

标签: cucumber

黄瓜V. 4.2.3 |硒V.3.8.1 | JUnit V.4.12 |范围报告V. 3.1.1

我在RunCuke的插件下集成了“ com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:”时遇到错误“ java.lang.NoClassDefFoundError:cucumber / runtime / io / URLOutputStream” 文件

package com.jacksparrow.automation.suite.runner;

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

@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features/functional/",
                     glue = {"com.jacksparrow.automation.steps_definitions.functional" },
                     tags = { "@guest_plp" },
                   plugin = { "pretty","json:target/cucumber-json/cucumber.json",
                              "junit:target/cucumber-reports/Cucumber.xml", "html:target/cucumber-reports",
                              "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"},
                   strict = false,
                   dryRun = false,
               monochrome = true)

public class FunctionalRunCuke {
}

Error Screen Shot from Eclipse

尝试在POM.xml中添加扩展黄瓜适配器,如下所示-

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

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

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

如果我删除“ extentreports-cucumber4-adapter”,那么我不会收到下面提到的编译时错误-

    java.lang.NoClassDefFoundError: cucumber/runtime/io/URLOutputStream
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
        at java.lang.Class.getConstructor0(Class.java:3075)
        at java.lang.Class.getConstructor(Class.java:1825)
        at cucumber.runtime.formatter.PluginFactory.findSingleArgConstructor(PluginFactory.java:141)
        at cucumber.runtime.formatter.PluginFactory.instantiate(PluginFactory.java:82)
        at cucumber.runtime.formatter.PluginFactory.create(PluginFactory.java:73)
        at cucumber.runtime.formatter.Plugins.createPlugins(Plugins.java:65)
        at cucumber.runtime.formatter.Plugins.<init>(Plugins.java:37)
        at cucumber.api.junit.Cucumber.<init>(Cucumber.java:94)
        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 org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
        at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:87)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:73)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:46)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:522)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
    Caused by: java.lang.ClassNotFoundException: cucumber.runtime.io.URLOutputStream
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 27 more

我在POM.xml中添加了以下依赖项

<!-- ********************************()() CUCUMBER & SELENIUM DEPENDENCIES ()()******************************** --> 

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>4.2.3</version>
</dependency>

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

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>datatable</artifactId>
    <version>1.1.12</version>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>4.2.3</version>
</dependency>

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

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.8.1</version>
</dependency>

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

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

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

以前有人遇到过此问题。 Cucumber V 4.2.3是否支持tentreports-cucumber4-adapter插件。如果是这样,则有任何猜测,这是什么错误导致了此错误。

3 个答案:

答案 0 :(得分:0)

出现此问题是因为您将ExtentReports版本3与黄瓜适配器一起使用,这仅适用于ExtentReports v4版本。如果删除依赖项不能解决问题,建议您共享pom.xml。

答案 1 :(得分:0)

@Grasshopper已提供解决方案,但在评论部分。因此,我想将其放置在主要部分中,因为某些用户可能不会浏览所有评论。

如果我们使用Cucumber-java版本> v4.2.0,则会看到此错误。因此,如果您使用的是最新版本,请将其降级为v4.2.0。

据您所知,这是我pom的样子:

    add_filter('woocommerce_short_description', 
    'filter_woocommerce_short_description',10, 1  );
    function filter_woocommerce_short_description( $short_description ) {
     global $product;

   $string_values = $product->get_attribute('agave');

   if ( strpos($string_values, 'agave') !== false ) {
  $short_description .= '<br>' . __("Testing This Out - AGAVE");
    }
   return $short_description;
   }

答案 2 :(得分:0)

通过添加以下依赖项可以解决上述问题

library(raster)
library(sp)
sub <- list.dirs(full.names=FALSE, recursive=FALSE)