【问题标题】:Unable to run simple cucumber program with java and Maven无法使用 java 和 Maven 运行简单的黄瓜程序
【发布时间】:2017-09-02 20:04:21
【问题描述】:

功能文件错误:

Unimplemented Subset definition

运行 Testrunner 类时出错

cucumber.runtime.CucumberException: Error parsing feature file search.feature

我正在使用 Intellij,创建 Maven 项目并在代码下方设置。我已经检查了子集插件,它似乎与最新版本一起安装到了 intelliJ 中。

已经尝试过与 stackoverflow 上其他问题不同的答案,但仍然无法运行。

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

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 : 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:

<?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>

【问题讨论】:

    标签: java maven intellij-idea cucumber cucumber-jvm


    【解决方案1】:

    问题来自Substeps IntelliJ Plugin,当 IntelliJ 在您的项目中找到 .feature 文件时建议您安装它。

    当它弹出时忽略此扩展程序,如果您已经拥有它,请卸载它。

    Cucumber for JavaGherkin 应该足够了。让我知道它是否有效。

    【讨论】:

    • 好的,现在我已经卸载了 Substeps IntelliJ 插件,重新启动 Intellij 并运行程序。出现错误:cucumber.runtime.CucumberException: Error parsing feature file search.feature
    • 在您的功能文件中,删除Feature: 之间的间距。 Scenario 也一样。
    • 非常感谢。我已经阅读并尝试了超过 25 种来自互联网的解决方案,但没有人告诉或建议我你在这里做了什么。问题已解决。
    猜你喜欢
    • 2017-11-09
    • 2015-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多