【发布时间】:2020-05-21 06:23:01
【问题描述】:
我尝试使用 Java 和 Maven 构建我的第一个可执行规范。我用这种结构创建了一个简单的项目:
specification
|-src
|-test
|-java
|-mypackage
|-MyFeatureTest.java
|-resources
|-MyFeature.feature
在junit测试MyFeatureTest.java我有这个:
import org.junit.runner.RunWith;
import cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
public class HomepageTest {
}
现在https://github.com/cucumber/cucumber-jvm/wiki/IDE-support 说我应该添加以下行:
@Cucumber.Options(paths={"my/super.feature:34"})
我尝试将其修改为
@Cucumber.Options(paths={"src/test/resources/"})
但是注释@Cucumber.Options 根本不可用。我的pom.xml 有这个依赖:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.0.0.RC20</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.0.0.RC20</version>
<scope>test</scope>
</dependency>
我错过了什么吗?
更新我遗漏了一些东西:黄瓜功能文件必须位于子目录 src/test/resources/mypackage/ 中。否则不会被junit测试拾取。
当我将它们放在同一目录src/main/test/ 中时,我可以运行我的功能测试,所以这对我来说不是一个障碍。但我想了解整个设置。
【问题讨论】:
标签: java cucumber cucumber-jvm cucumber-junit