首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >版本1.0.14之后的cucumber-java和cucumber-junit不起作用

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

Stack Overflow用户
提问于 2015-07-08 15:10:28
回答 7查看 34.8K关注 0票数 5

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

代码语言:javascript
复制
<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文件的内容为:

代码语言:javascript
复制
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 {
}

我在以下几行代码中得到了错误:

代码语言:javascript
复制
import cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})

但当我使用1.0.14版本时,它工作得很好。最新版本有什么问题?

EN

回答 7

Stack Overflow用户

发布于 2015-07-08 17:30:06

@Cucumber.Optionsdeprecated,请改用@CucumberOptions

代码语言:javascript
复制
@CucumberOptions(
    format = "pretty",
    features = "//refer to Feature file"  
)

希望这能对你有所帮助

票数 9
EN

Stack Overflow用户

发布于 2015-07-08 17:29:56

批注已更改为@CucumberOptions

我认为在这个黄瓜版本中json-pretty已经改成了json

这应该是可行的:

代码语言:javascript
复制
@CucumberOptions(
      format = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}
)

而且,根据cucumber-jvm specifications格式是不推荐使用的。您应该替换为plugin。这也应该是可行的:

代码语言:javascript
复制
plugin = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}

希望能有所帮助

票数 5
EN

Stack Overflow用户

发布于 2015-07-08 17:30:47

使用cucumber 1.2.2

代码语言:javascript
复制
<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>
....

下面是一个工作测试示例:

代码语言:javascript
复制
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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31285776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档