简体   繁体   English

错误:无法找到或加载主类cucumber.api.cli.Main

[英]Error: Could not find or load main class cucumber.api.cli.Main

I try to run this gradle task 我尝试运行这个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
}

and get this error: 并得到此错误:

Error: Could not find or load main class cucumber.api.cli.Main

why is that? 这是为什么? I can find it in the included cucumber jar. 我可以在附带的黄瓜罐中找到它。

Edit 编辑

I already have this task that runs successfully: 我已经成功运行了这个任务:

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'
    }

The following script works in terms of proper configuration but fails since there are now features/test to check. 以下脚本在正确配置方面有效但由于现在要检查功能/测试而失败。

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
}

This is how JavaExec classpath should be modified. 这是应该修改JavaExec类路径的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java Cucumber - 错误:无法找到或加载主类 Cucumber.api.cli.Main - Java cucumber - Error: Could not find or load main class cucumber.api.cli.Main 测试运行,但是:无法找到或加载主类cucumber.api.cli.Main - Test run, but: Could not find or load main class cucumber.api.cli.Main Cucumber 测试 - 找不到类 cucumber.api.cli.Main - Cucumber test - could not find classs cucumber.api.cli.Main 无法在Eclipse中使用Gradle运行黄瓜功能文件。 我收到“错误:无法找到或加载主类Cucumber.api.cli.Main”错误 - Unable to run cucumber feature file using gradle in Eclipse. I am getting “Error: Could not find or load main class cucumber.api.cli.Main” error 错误:无法找到或加载主类 cucumber.cli.Main - Error: Could not find or load main class cucumber.cli.Main CLI runner cucumber.api.cli.Main 找不到步骤定义 - CLI runner cucumber.api.cli.Main cannot find step definitions javacumul.api.cli.main命令行用法 - java cucumber.api.cli.main command line usage Java Cucumber CLI(cucumber.api.cli.Main)的--glue选项的语法 - Syntax of --glue option for Java Cucumber cli (cucumber.api.cli.Main) 基本黄瓜测试项目-如何运行javacumber.api.cli.Main? - Basic Cucumber test project - how to run java cucumber.api.cli.Main? 错误:找不到或加载主类Main - Error: Could not find or load main class Main
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM