cucumber.runtime.CucumberException:无法加载插件 class:io.qameta.allure.cucumberjvm.AllureCucumberJvm
cucumber.runtime.CucumberException: Couldn't load plugin class: io.qameta.allure.cucumberjvm.AllureCucumberJvm
我已经将 Alluer 集成到我的黄瓜自动化项目中。集成后,我可以 运行 从功能文件中进行测试,并成功生成报告。但是,当我尝试 运行 从测试条目 class 进行测试时,出现了异常。有人可以帮我弄这个吗?非常感谢。
错误信息:
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)
条目class:
@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>
问题是您使用的是旧的 allure-cucumber-jvm-adaptor
依赖项。正确的是
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber-jvm</artifactId>
<version>2.0-BETA16</version>
</dependency>
也不需要指定额外的allure-java-commons
依赖
我已经将 Alluer 集成到我的黄瓜自动化项目中。集成后,我可以 运行 从功能文件中进行测试,并成功生成报告。但是,当我尝试 运行 从测试条目 class 进行测试时,出现了异常。有人可以帮我弄这个吗?非常感谢。
错误信息:
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)
条目class:
@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>
问题是您使用的是旧的 allure-cucumber-jvm-adaptor
依赖项。正确的是
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber-jvm</artifactId>
<version>2.0-BETA16</version>
</dependency>
也不需要指定额外的allure-java-commons
依赖