我同时使用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>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 {
}我在以下几行代码中得到了错误:
import cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})但当我使用1.0.14版本时,它工作得很好。最新版本有什么问题?
发布于 2015-07-08 17:30:06
@Cucumber.Options为deprecated,请改用@CucumberOptions
@CucumberOptions(
format = "pretty",
features = "//refer to Feature file"
)希望这能对你有所帮助
发布于 2015-07-08 17:29:56
批注已更改为@CucumberOptions
我认为在这个黄瓜版本中json-pretty已经改成了json。
这应该是可行的:
@CucumberOptions(
format = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}
)而且,根据cucumber-jvm specifications格式是不推荐使用的。您应该替换为plugin。这也应该是可行的:
plugin = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}希望能有所帮助
发布于 2015-07-08 17:30:47
使用cucumber 1.2.2
<cucumber.version>1.2.2</cucumber.version>
....
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
....下面是一个工作测试示例:
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features/myfeature.feature", tags = "@Mytag", plugin = {"pretty", "html:target/cucumber"})
public class MYAcceptanceTest {
}注意,导入是cucumber.api.junit.Cucumber而不是cucumber.junit.Cucumber,您需要为cucumber选项添加导入。该选项的构造型是@CucumberOptions而不是@Cucumber.Options
https://stackoverflow.com/questions/31285776
复制相似问题