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

Java 错误:无法找到或加载主类cucumber.api.cli.main,java,intellij-idea,gradle,cucumber,build.gradle,Java,Intellij Idea,Gradle,Cucumber,Build.gradle,我尝试运行这个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/featu

我尝试运行这个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
}
并获取以下错误:

错误:无法找到或加载主类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'
    }

以下脚本在正确配置方面工作,但由于现在有功能/测试需要检查,因此失败

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
类路径的修改方式。

您需要通过
classpath
属性将cucumber jar添加到
runcucucumber
任务类路径。但是为什么“run”没有类路径运行?我不明白。它有一个类路径,但您没有将Cumber jar传递给该类路径。那么它是如何工作的呢?你能把你的意思写下来吗
runcumber{classpath jarName}
请参见ma答案,如果它解决了问题,请接受。谁填写
configurations{cumber}
以及它如何确定值?这是一个不同的问题(关于gradle内部)。它是由我定义的,这样的自定义配置可以在gradle中定义。我添加它是为了有一个定义良好的cucumber dependencies。它可以运行,但a)我得到缺少步骤的错误(即使它们已经实现)
23:51:46.359[QUIET][system.out]您可以使用下面的代码段实现缺少的步骤:23:51:46.360[QUIET][system.out]@Given(“^here exists a admin logged in client$”)23:51:46.361[QUIET][system.out]public void there_exists_an_admin_logged_in_client()抛出可丢弃的{23:51:46.361[QUIET][system.out]//在此处编写代码,将上述短语转化为具体操作23:51:46.362[QUIET][system.out]抛出新的PendingException();23:51:46.362[QUIET][system.out]}
几秒钟后任务也会完成。我的测试没有真正运行。
23:51:46.459[DEBUG][org.gradle.launcher.daemon.server.SynchronizedDispatchConnection]线程15:调度类org.gradle.launcher.daemon.protocol.Success 11:51:46 PM:外部任务执行完成“RunCumber”。
尽管执行通常需要10分钟以上抱歉,但我不知道您的项目内部结构和配置。最初的问题是关于缺少类的,据我所知已回答。如果是,请回答在单独的线程中接受并发布新问题。