2017-04-23 21 views
0

我想開始用黃瓜測試,創造了simpliest test.feature文件:黃瓜test.feature沒有看到我的腳步

Feature: XYZ 
Scenario: S1 
    When I am on x page 
    Then I see the element 

,並創建步驟

import cucumber.api.java.en.Then; 
import cucumber.api.java.en.When; 

    public class MyStepdefs { 
     @When("^I am on x page$") 
     public void iAmOnXPage() { 
      System.out.println("I'm on page"); 
     } 

     @Then("^I see the element$") 
     public void iSeeTheElement() throws Throwable { 
      System.out.println("I see dead people"); 
     } 
    } 

我已經全部安裝插件需要: - 黃瓜對Java - 黃瓜對Groovy - 小黃瓜 文件的結構是:

enter image description here

此外,test/java文件夾在Maven中被標記爲測試源文件夾。 我也嘗試在Maven中重新啓動IntelliJ和Reimport項目,沒有什麼幫助。有什麼建議麼?

回答

1

好吧,我已經找到了一個解決方案,我創建了額外的TestRunner類:

import cucumber.api.junit.Cucumber; 
import org.junit.runner.RunWith; 
import cucumber.api.CucumberOptions; 

@RunWith(Cucumber.class) 
@CucumberOptions(
     features={"src/test/resources"} 
) 

public class testRunner { 
} 

這不是在我檢查了幾個教程提及,但發現它在https://www.stevefenton.co.uk/2015/01/getting-started-with-bdd-intellij/ 後的微小變化(如@ Cucumber.Options - > @CucumberOptions)它的工作:)