java - 无法用java和Maven运行简单的cucumber程序

标签 java maven intellij-idea cucumber cucumber-jvm

功能文件中的错误:

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>

Project Structure

最佳答案

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

当此扩展程序弹出时只需忽略它,或者如果您已经安装了它,请将其卸载。

Cucumber for JavaGherkin 应该足够了。如果成功请告诉我。

关于java - 无法用java和Maven运行简单的cucumber程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46017712/

相关文章:

java - 获取 JTextArea 中的位置并使用计时器

java - 如何从 Spring Boot 项目创建 jar,我们想在另一个 Spring Boot 应用程序中使用这个 jar?

intellij-idea - 在 IntelliJ 中 A.B 的包 A 中创建类

android - 无法访问继承的库

intellij-idea - Android Studio : How to attach javadoc

css - 如何在Intellij IDEA中获取Web Essentials的特性

java - 如何将 currentLocation ActivityOne 传递给 ActivityTwo?

java - 将运行时参数传递给 DockerFile 中的 JAR 未运行

maven - 如何为docker配置Maven/Spring Boot项目pom.xml?

maven - 故障安全错误 : "Invalid signature file digest for Manifest main attributes" when using shade plugin