cucumber-junit-platform-engine 中的@CucumberOptions

@CucumberOptions in cucumber-junit-platform-engine

我正在尝试将我的 Cucumber 测试从 cucumber-junit 迁移到 cucumber-junit-platform-engine,以便能够使用新的平台功能。如何重新定义我的跑步者以使用旧 @CucumberOptions。我正在调查这个问题,但似乎还没有找到正确的方法。

在我使用这些选项之前:

@CucumberOptions(
  plugin = ...,
  features = ...,
  tags = ...,
  glue = ...
)

是否有直接的方法将其迁移到平台引擎?

直到 Junit5/#2416 is merged there is no 1-to-1 replacement. However if you only have a single class annotated with @CucumberOptions adding properties to junit-platform.properties 应该足够了。

编辑:#2416 已合并并发布。您现在可以使用不同配置的 运行 黄瓜套件。参见 cucumber-junit-platform docs

看起来 junit-platform-engine 中的 @Suite 应该使用正确的引擎而不是黄瓜注释。

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("features")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example")
public class RunCucumberTest {
}

感谢@spmason

过去几天我一直在研究 JUnit5Cucumber 7.0,我只是添加到你自己的答案中。 文档很少,这 link has been a bless and docs

你不必使用 @IncludeEngines 还要注意包的引用方式

@Suite
@SelectClasspathResource("com/rmdaw/cucumber/features")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.rmdaw.repository")

最后你可以将配置放入 test/java/resources/junit-platform.properties 里面你可以有这样的东西:

cucumber.publish.quiet=true
cucumber.glue=com.rmdaw.cucumber
cucumber.plugin=pretty,\
            html:target/SystemTestReports/report.html,\
            json:target/SystemTestReports/report.json,\
            junit:target/SystemTestReports/junit.xml\