'Gradle cucumber' testImplementation 不工作
'Gradle cucumber' With testImplementation Not Working
我正在构建一个使用 Cucumber 的简单测试应用程序。不幸的是,当我尝试 运行 时,'gradle cucumber' 会抛出错误。然而,当我将 testImplement 更改为 build.gradle 中已弃用的 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
谁能解释一下这是怎么回事?非常感谢任何帮助!
请参阅 here,其中表示 testRuntime 已弃用
The compile, testCompile, runtime and testRuntime configurations inherited from the Java plugin are still available but are deprecated
我觉得应该是
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
我正在构建一个使用 Cucumber 的简单测试应用程序。不幸的是,当我尝试 运行 时,'gradle cucumber' 会抛出错误。然而,当我将 testImplement 更改为 build.gradle 中已弃用的 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
谁能解释一下这是怎么回事?非常感谢任何帮助!
请参阅 here,其中表示 testRuntime 已弃用
The compile, testCompile, runtime and testRuntime configurations inherited from the Java plugin are still available but are deprecated
我觉得应该是
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}