[英]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
I am trying to run cucumber feature file on Eclipse but getting following error. 我正在尝试在Eclipse上运行黄瓜功能文件,但出现以下错误。 "Error: Could not find or load main class cucumber.api.cli.Main" “错误:找不到或加载主类Cucumber.api.cli.Main”
Gradle code ( build.gradle ) 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()
}
Feature file ( add.Feature ) 功能文件( 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
I am right clicking on feature file. 我右键单击功能文件。 Then selecting run as and pressing on cucumber feature. 然后选择运行方式并按黄瓜功能。 Thanks in advance. 提前致谢。
I forgot to add runner class. 我忘了加跑步者课。 Below is the code for runner class. 以下是跑步者课程的代码。 After adding this class, I am able to run the feature file 添加此类后,我可以运行功能文件
runcukestest.java 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 {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.