Feature files discovery in cucumber-junit-platform-engine(cucumber-junit-platform-engine 中的功能文件发现)
问题描述
在 cucumber-junit
库中,我使用 @CucumberOptions
来定义功能文件位置:
In cucumber-junit
library I use @CucumberOptions
to define feature files location:
package com.mycompany.cucumber;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = ...,
features = "classpath:.", // my java step definitions are in package com.mycompany.cucumber
// but feature files directly in test resources
// resources/is_it_friday_yet.feature
tags = ...,
glue = ...
)
public class CucumberRunner {
}
我正在使用自定义 gradle 任务 cucumberTest
I'm running my tests with custom gradle task cucumberTest
cucumberTest {
useJUnitPlatform()
}
迁移到 cucumber-junit-platform-engine
后,不再支持 @CucumberOptions
.
After migrating to cucumber-junit-platform-engine
@CucumberOptions
are no longer supported.
package com.mycompany.cucumber;
import io.cucumber.junit.platform.engine.Cucumber;
@Cucumber
public class CucumberRunner {
}
我可以通过将 plugin
、tags
、glue
选项替换为属性 cucumber.filter.tags
, cucumber.glue
, cucumber.plugin
.
I can make it work with replacing plugin
, tags
, glue
options with properties cucumber.filter.tags
, cucumber.glue
, cucumber.plugin
.
features
属性呢?如果我更改功能文件位置以匹配包名称,即 resources/com/mycompany/cucumber/is_it_friday_yet.feature
,它工作正常.这仍然是一个简单的案例,我还有更多的测试包没有放在与源代码相同的位置,我无法移动它们.
What about features
property? It works fine if I change feature files location to match package name i.e. resources/com/mycompany/cucumber/is_it_friday_yet.feature
. Still this is a simple case and I have many more test packages which are not placed in the same locations as source code and I cannot move them.
推荐答案
Gradle不支持基于非类的测试引擎.但是,您可以创建 自定义任务使用 JUnit Platform ConsoleLauncher.然后,您可以使用 Junit 5 选择器 即 支持 Cucumber 选择您的功能.例如 FileSelector
和 --select-file
.
Gradle doesn't support non-class based test engines. However you can create a custom task that uses the JUnit Platform ConsoleLauncher. You can then use the Junit 5 selectors that are supported by Cucumber to select your features. For example the FileSelector
with --select-file
.
val consoleLauncherTest by tasks.creating(JavaExec::class) {
dependsOn("testClasses")
val reportsDir = file("$buildDir/test-results")
outputs.dir(reportsDir)
classpath(sourceSets["test"].runtimeClasspath)
main = "org.junit.platform.console.ConsoleLauncher"
args("--select-file", "path/to.feature")
args("--details", "tree")
args("--reports-dir", reportsDir)
}
这篇关于cucumber-junit-platform-engine 中的功能文件发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:cucumber-junit-platform-engine 中的功能文件发现


- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 转换 ldap 日期 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 获取数字的最后一位 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01