[英]Unable to run simple cucumber program with java and Maven
Error in Feature file : 功能文件中的错误:
Unimplemented Subset definition
Error when Run Testrunner class 运行Testrunner类时出错
cucumber.runtime.CucumberException: Error parsing feature file search.feature
I am using Intellij , Created Maven project and setup below code. 我正在使用Intellij,Created Maven项目和下面的代码设置。 I have already checked for subset plugin and it seems installed with latest version into intelliJ.
我已经检查了子集插件,并且似乎已将最新版本安装到intelliJ中。
Already tried different answers from other questions on stackoverflow but still unable to run it. 已经对stackoverflow尝试了其他问题的其他答案,但仍然无法运行。
TestRunner.java TestRunner.java
package runner;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/resources/features/",glue={"stepDefinition"})
public class TestRunner{
}
SmokeTest.java SmokeTest.java
package stepDefinition;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class SmokeTest {
@Given("^I am on the home page$")
public void iAmOnTheHomePage() throws Throwable {
System.out.println("1");
}
@When("^I select to search for game$")
public void iSelectToSearchForGame() throws Throwable {
System.out.println("2");
}
@Then("^I get the search results with game names at the top$")
public void iGetTheSearchResultsWithGameResultsAtTheTop() throws Throwable {
System.out.println("3");
}
}
Feature : 特点:
Feature : search
Scenario : Searching as a Global user
Given I am on the home page
When I select to search for game
Then I get the search results with game names at the top
POM.xml : POM.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo.cucumber</groupId>
<artifactId>com.demo.cucumber</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.24</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.5.3</version>
</dependency>
</dependencies>
</project>
The issue is from Substeps IntelliJ Plugin
that IntelliJ suggests you install when it locates a .feature
file inside your project. 问题出在IntelliJ建议您在项目内找到
.feature
文件时安装的Substeps IntelliJ Plugin
。
Just ignore this extension when it pops up or uninstall it if you already have it. 只需在弹出该扩展名时忽略它即可;如果已有扩展名,则将其卸载。
Cucumber for Java
and Gherkin
should be enough. Cucumber for Java
和Gherkin
应该足够了。 Let me know if it works out. 让我知道是否可行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.