【发布时间】:2020-06-20 15:32:08
【问题描述】:
我使用 Junit5 和 Cucumber 创建了一个小型 sn-p Spring Boot 应用程序。
因为我需要使用 Junit5,所以我使用的是 cucumber-junit-platform-engine,它不支持注解 CucumberOptions
如 cucumber.io 网站所引:
当运行器(即 cucumber-junit-platform-engine)未提供属性解析功能时,Cucumber 将按优先顺序从系统属性、环境变量和 cucumber.properties 文件中解析属性。
因此,我将以下名为 cucumber.properties 的文件添加到我的目录 src/test/resources 中,内容如下:
cucumber.plugin=json:target/cucumber-reports/,pretty
然而,当我运行我的测试时,这个文件似乎被忽略了,因为如果我通过 cli 参数传递相同的属性,例如:
mvn test -Dcucumber.plugin=json:target/cucumber-reports/,pretty 它会生成预期的 json 报告。
我也尝试将文件放在src/main/resources 和src/main/test/cucumber.demo(功能文件所在的位置)下,但这些尝试都没有奏效。知道为什么文件被忽略了吗?
这是我的 Runner 课程:
@Cucumber
public class CucumberTest {
}
和我的步骤定义类:
@CucumberContextConfiguration
@SpringBootTest
public class StepDefinition {
@Autowired
String bean;
//Step Definition
(...)
}
【问题讨论】:
标签: java testing junit cucumber junit5