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
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
我正在尝试 运行 Eclipse 上的 cucumber 功能文件,但出现以下错误。
"Error: Could not find or load main class cucumber.api.cli.Main"
Gradle代码(build.gradle)
apply plugin: 'java'
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 {
testCompile 'io.cucumber:cucumber-java:3.0.2'
testCompile 'io.cucumber:cucumber-junit:3.0.2'
testCompile 'junit:junit:4.12'
}
repositories {
mavenCentral()
}
专题文件(add.Feature)
@tag
Feature: Title of your feature
I want to use this template for my feature file
@tag1
Scenario: Title of your scenario
Given I have the calculator
When I enter input1 and input2
And I press add button
Then I get output
我正在右键单击功能文件。然后选择 运行 作为并按下黄瓜功能。
提前致谢。
我忘了添加 运行ner class。
下面是 运行ner class 的代码。添加此 class 后,我可以 运行 功能文件
runcukestest.java
package cucumber;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty"})
public class runcukestest {
}
我正在尝试 运行 Eclipse 上的 cucumber 功能文件,但出现以下错误。 "Error: Could not find or load main class cucumber.api.cli.Main"
Gradle代码(build.gradle)
apply plugin: 'java'
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 {
testCompile 'io.cucumber:cucumber-java:3.0.2'
testCompile 'io.cucumber:cucumber-junit:3.0.2'
testCompile 'junit:junit:4.12'
}
repositories {
mavenCentral()
}
专题文件(add.Feature)
@tag
Feature: Title of your feature
I want to use this template for my feature file
@tag1
Scenario: Title of your scenario
Given I have the calculator
When I enter input1 and input2
And I press add button
Then I get output
我正在右键单击功能文件。然后选择 运行 作为并按下黄瓜功能。 提前致谢。
我忘了添加 运行ner class。 下面是 运行ner class 的代码。添加此 class 后,我可以 运行 功能文件
runcukestest.java
package cucumber;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty"})
public class runcukestest {
}