我正在构建一个使用黄瓜的简单测试应用程序。不幸的是,当我尝试运行它时,“ 渐变黄瓜”会引发错误。但是,当我在build.gradle中将testImplement更改为已弃用的testCompile时,一切运行正常。这是预期的行为吗?要使用testImplementation使黄瓜运行,我该怎么办?
build.gradle:
dependencies {
testImplementation 'io.cucumber:cucumber-java:4.2.0'
testImplementation 'io.cucumber:cucumber-junit:4.2.0'
}
configurations {
cucumberRuntime {
extendsFrom testRuntime
}
}
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "cucumber.api.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty', '--glue', 'gradle.cucumber', 'src/test/resources']
}
}
}
结果(错误):
> Task :cucumber FAILED
Error: Could not find or load main class cucumber.api.cli.Main
Caused by: java.lang.ClassNotFoundException: cucumber.api.cli.Main
build.gradle:
dependencies {
testCompile 'io.cucumber:cucumber-java:4.2.0'
testCompile 'io.cucumber:cucumber-junit:4.2.0'
}
...
结果(可行):
> Task :cucumber
No features found at [src/test/resources]
0 Scenarios
0 Steps
有人可以解释这里发生了什么吗?任何帮助将不胜感激!
答案 0 :(得分:2)
请参见here,其中表明testRuntime已弃用
从Java插件继承的compile,testCompile,runtime和testRuntime配置仍然可用,但已弃用
我认为应该是
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}