版本1.0.14之后的cucumber-java和cucumber-junit不起作用

Rip*_*sim 5 eclipse cucumber cucumber-jvm cucumber-junit selenium-webdriver

我一起使用Cucumber-JVM和Selenium WebDriver.我在eclipse中有一个Maven项目,pom.xml文件的依赖关系如下:

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.2.2</version>
    <scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

RunCukesTest.java文件的内容是:

import org.junit.runner.RunWith;
import cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})
public class RunCukesTest {
}
Run Code Online (Sandbox Code Playgroud)

我在以下代码行中收到错误:

import cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})
Run Code Online (Sandbox Code Playgroud)

但是,当我使用1.0.14版时,它运行良好.最新版本有什么问题?

Vic*_*cky 9

@Cucumber.Options弃用的使用@CucumberOptions,而不是

@CucumberOptions(
    format = "pretty",
    features = "//refer to Feature file"  
)
Run Code Online (Sandbox Code Playgroud)

希望这对你有所帮助


tro*_*oig 5

注释已更改为@CucumberOptions:

而且我认为json-pretty已经改变json了这个黄瓜版本.

这应该工作:

@CucumberOptions(
      format = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}
)
Run Code Online (Sandbox Code Playgroud)

而且,根据cucumber-jvm规范格式不推荐使用.你应该替换plugin.这也应该有效:

plugin = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你