我尝试将Cucumber JVM 2与Allure 2结合使用,我遇到了麻烦。当我尝试运行我的Maven项目时 - 出现以下错误:
cucumber.runtime.CucumberException: Couldn't load plugin class:
io.qameta.allure.cucumberjvm.AllureCucumberJvm. It does not implement
cucumber.api.Plugin
我尝试使用CucumberOptions指定Allure插件,如下所示:
@RunWith(Cucumber.class)
@CucumberOptions
(
features="src/test/resources/com/ss/cuketest/features/SomeFeature.feature"
, glue="com/ss/cuketest/steps"
, plugin= {"io.qameta.allure.cucumberjvm.AllureCucumberJvm"}
)
public class SomeRunner {
}
AllureCucumberJvm声明如下所示:
public class AllureCucumberJvm implements Reporter, Formatter
所以问题是Allure的2 Cucumber JVM适配器是否与Cucumber JVM 2兼容?或者我应该使用别的东西?
PS:在我的pom中,我使用下面的依赖项:
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber-jvm</artifactId>
<version>2.0-BETA21</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>2.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.3.1</version>
</dependency>
非常感谢任何帮助。 感谢。
答案 0 :(得分:3)
根据Cucumber源文件cucumber.api.Plugin,现在需要任何插件来实现以下接口之一:
* <li>{@link cucumber.api.StepDefinitionReporter}</li>
* <li>{@link cucumber.api.SummaryPrinter}</li>
* <li>{@link cucumber.api.formatter.Formatter}</li>
然而AllureCucumberJvm实现了
gherkin.formatter.Formatter
代替。因此,为AllureCucumberJvm编写一个实现插件接口的简单扩展并不令人惊讶(但我的测试运行正常)。
我相信Allure团队应该解决这个问题。
答案 1 :(得分:1)
你试过这个https://github.com/allure-framework/allure-java/tree/master/allure-cucumber2-jvm吗? 这适用于cucumber-jvm2
答案 2 :(得分:0)
要详细介绍Viktor Sidochenko's answer,以下是POM文件中的必填行:
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber2-jvm</artifactId>
<version>LATEST</version>
</dependency>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
-Dcucumber.options="--plugin io.qameta.allure.cucumber2jvm.AllureCucumber2Jvm"
</argLine>