gpt4 book ai didi

java - Cucumber-junit-platform-engine 中的特征文件发现

转载 作者:行者123 更新时间:2023-12-03 03:53:16 24 4
gpt4 key购买 nike

cucumber-junit我使用的图书馆 @CucumberOptions定义特征文件位置:

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
cucumberTest {
useJUnitPlatform()
}
迁移到 cucumber-junit-platform-engine@CucumberOptions不再支持。
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 .
怎么样 features属性(property)?如果我更改功能文件位置以匹配包名称,即 resources/com/mycompany/cucumber/is_it_friday_yet.feature,它工作正常.这仍然是一个简单的案例,我有更多的测试包,它们没有与源代码放在相同的位置,我无法移动它们。

最佳答案

Gradle doesn't support non-class based test engines .但是您可以创建 a custom task that uses the JUnit Platform ConsoleLauncher .然后您可以使用 Junit 5 selectorssupported by Cucumber选择您的功能。例如 FileSelector--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)
}

关于java - Cucumber-junit-platform-engine 中的特征文件发现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64676559/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com