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 中的功能文件发现
基础教程推荐
- 如何强制对超级方法进行多态调用? 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01