cucumber.runtime.CucumberException:无法加载插件类:io.qameta.allure.cucumberjvm.AllureCucumberJvm

时间:2017-08-15 23:42:38

标签: java maven cucumber allure

我已将Alluer整合到我的黄瓜自动化项目中。集成后,我可以从功能文件运行测试,并成功生成报告。但是,当我尝试从测试入口类运行测试时,出现了异常。有人可以帮我弄这个吗?非常感谢你。

错误讯息:

cucumber.runtime.CucumberException: Couldn't load plugin class: io.qameta.allure.cucumberjvm.AllureCucumberJvm

    at cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:175)
    at cucumber.runtime.formatter.PluginFactory.pluginClass(PluginFactory.java:165)
    at cucumber.runtime.formatter.PluginFactory.getPluginClass(PluginFactory.java:226)
    at cucumber.runtime.formatter.PluginFactory.isFormatterName(PluginFactory.java:195)
    at cucumber.runtime.RuntimeOptions$ParsedPluginData.addPluginName(RuntimeOptions.java:365)
    at cucumber.runtime.RuntimeOptions.parse(RuntimeOptions.java:125)
    at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:89)
    at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:78)
    at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:70)
    at cucumber.runtime.RuntimeOptionsFactory.create(RuntimeOptionsFactory.java:25)
    at cucumber.api.junit.Cucumber.<init>(Cucumber.java:56)
    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:422)
    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 com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
    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: io.qameta.allure.cucumberjvm.AllureCucumberJvm
    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)
    at cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:173)

入门级:

@RunWith(Cucumber.class)
@CucumberOptions(
        features = {"src/test/resources/features"},
        glue = {"classpath:com.wi***rd.step"},
        format = {"pretty", "html:target/cucumber-report", "json:target/cucumber.json"},
        tags = {"@Mer***tion, @Add***nal, @MER***CH, @MER***ERR"}
)
public class A***dApplicationTests {
}

的pom.xml

        <dependency>
            <groupId>ru.yandex.qatools.allure</groupId>
            <artifactId>allure-cucumber-jvm-adaptor</artifactId>
            <version>1.6.3</version>
        </dependency>
        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-java-commons</artifactId>
            <version>2.0-BETA15</version>
        </dependency>        
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                        -Dcucumber.options="--plugin io.qameta.allure.cucumberjvm.AllureCucumberJvm"
                    </argLine>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>1.8.10</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>

    </build>

1 个答案:

答案 0 :(得分:1)

问题是您使用旧的allure-cucumber-jvm-adaptor依赖项。正确的是

<dependency>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-cucumber-jvm</artifactId>
    <version>2.0-BETA16</version>
</dependency>

此外,无需指定其他allure-java-commons依赖项