2017-09-02 29 views
1

錯誤特徵文件運行簡單的黃瓜程序:無法與Java和Maven

Unimplemented Subset definition 

錯誤時運行的TestRunner類

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

我使用的IntelliJ,創建Maven項目和設置下面的代碼。我已經檢查過子集插件,它似乎已安裝到intelliJ的最新版本。

已經嘗試了不同的答案從其他問題上的計算器,但仍然無法運行它。

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

回答

2

的問題是從Substeps IntelliJ Plugin說的IntelliJ建議您安裝時,它找到了一個.feature文件的項目中。

如果您已經擁有它,只需在彈出或卸載它時忽略此擴展名即可。

Cucumber for Java and Gherkin應該足夠了。讓我知道它是否成功。

+0

好吧現在我已經卸載Substeps IntelliJ插件,重新啓動Intellij並運行程序。獲取錯誤:'cucumber.runtime.CucumberException:解析特徵文件search.feature時出錯' –

+0

在你的特徵文件中,刪除'Feature'和':'之間的間距。 'Scenario'也一樣。 –

+0

非常感謝。我已經閱讀並嘗試了超過25種來自互聯網的解決方案,但沒有人告訴我或在這裏建議你做了什麼。問題解決了。 –