我尝试运行这个gradle任务
task runCucumber(type: JavaExec) {
main = "cucumber.api.cli.Main"
args += ['-f', 'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue', 'com.waze.testing.cucumber', 'src/main/resources/features'
, '--tags', '~@ignore', '--tags', '~@preRelease', '--tags', '@advil']
systemProperties['http.keepAlive'] = 'false'
systemProperties['http.maxRedirects'] = '20'
ignoreExitValue = true
}
并收到此错误:
Error: Could not find or load main class cucumber.api.cli.Main
为什么?我可以在附带的黄瓜罐中找到它。
修改
我已经成功运行此任务:
mainClassName = "cucumber.api.cli.Main"
run {
args += ['-f', 'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue', 'com.waze.testing.cucumber', 'src/main/resources/features'
, '--tags', '~@ignore', '--tags', '~@preRelease']
systemProperties['http.keepAlive'] = 'false'
systemProperties['http.maxRedirects'] = '20'
}
答案 0 :(得分:1)
以下脚本在正确配置方面有效,但由于现在要检查功能/测试,因此失败了。
apply plugin: 'java'
repositories {
mavenCentral()
}
configurations {
cucumber
}
dependencies {
cucumber 'info.cukes:cucumber-java:1.2.2'
}
task runCucumber(type: JavaExec) {
main = "cucumber.api.cli.Main"
args += ['-f', 'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue', 'com.waze.testing.cucumber', 'src/main/resources/features'
, '--tags', '~@ignore', '--tags', '~@preRelease', '--tags', '@advil']
systemProperties['http.keepAlive'] = 'false'
systemProperties['http.maxRedirects'] = '20'
ignoreExitValue = true
classpath = configurations.cucumber
}
这是JavaExec
类路径的修改方式。