这是我的gradle设置。
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']
}
}
}
dependencies {
compile 'org.apache.commons:commons-lang3:3.7'
testCompile 'io.cucumber:gherkin:5.0.0'
testCompile 'io.cucumber:cucumber-java:2.4.0'
testCompile 'io.cucumber:cucumber-core:2.4.0'
testCompile 'io.cucumber:cucumber-junit:2.4.0'
}
当我从gradle命令启动黄瓜时,一切正常,但是当我通过右键单击从intellij运行功能时,我得到以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/IGherkinDialectProvider
Caused by: java.lang.ClassNotFoundException: gherkin.IGherkinDialectProvider
我已经读到这可能是由于小黄瓜依赖性兼容性而发生的,所以我尝试与其他小黄瓜版本交换,但它没有帮助。