我如何使用cumulan-junit设置黄瓜功能?
问题内容:
我尝试使用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/
,因此对我来说不是障碍。但我想了解整个设置。
问题答案:
在这里看看我的问题:
您可以通过在选项注解中设置feature属性来指定类路径上的位置,例如
@Cucumber.Options(features="src/test/resources")
编辑:
在新版本中,代码为
@CucumberOptions(features="src/test/resources")