2017-12-14 23 views
0

Java 용 Cucumber를 사용하여 HelloWorld 유형의 테스트를하고 있습니다.오이가 기능 단계를 찾을 수 없습니다.

가 나는 기능

Feature: To check that main tutorial course pages have loaded in TheTestRoom.com 

    Scenario: To check that the WebDriver Cucumber tutorial main page has loaded 
    Given I navigate to TheTestRoom.com 
    When I navigate to Cucumber Tutorial page 
    Then the page title should be visible 

정의 그리고 그것은 클래스 패스에 컴파일 된 클래스 경로를 추가, 나는 단계 정의 클래스를 컴파일하고 테스트를 실행하기 위해 자바를 사용하여 사용해서 더미 implmentation

package step_definition; 

    import cucumber.api.java.en.*; 
    import cucumber.api.PendingException; 

    public class myFirstStepDefinition { 

      @Given("^I navigate to TheTestRoom\\ .com$") 
      public void i_navigate_to_TheTestRoom_com() throws Throwable { 
        // Write code here that turns the phrase above into concrete actions 
        throw new PendingException(); 
      } 
      @When("^I navigate to Cucumber Tutorial page$") 
      public void i_navigate_to_Cucumber_Tutorial_page() throws Throwable { 
        // Write code here that turns the phrase above into concrete actions 
        throw new PendingException(); 
      } 
      @Then("^the page title should be visible$") 
      public void the_page_title_should_be_visible() throws Throwable { 
        // Write code here that turns the phrase above into concrete actions 
        throw new PendingException(); 
      } 
    } 

입니다

"C:\Program Files\Java\jdk-9.0.1\bin\java" -cp "C:\OutSystems\HelloWorld\dependency\*;C:\OutSystems\HelloWorld\step_definition\*" cucumber.api.cli.Main -p pretty -g step_definition C:\OutSystems\HelloWorld\feature\ 

그러나 출력은 기능 단계가없는 것처럼 보입니다.

Feature: To check that main tutorial course pages have loaded in TheTestRoom.com 

    Scenario: To check that the WebDriver Cucumber tutorial main page has loaded [90m# features.feature:3[0m 
    [33mGiven [0m[33mI navigate to TheTestRoom.com[0m 
    [33mWhen [0m[33mI navigate to Cucumber Tutorial page[0m 
    [33mThen [0m[33mthe page title should be visible[0m 

    1 Scenarios ([33m1 undefined[0m) 
    3 Steps ([33m3 undefined[0m) 
    0m0.000s 


    You can implement missing steps with the snippets below: 

      @Given("^I navigate to TheTestRoom\\ .com$") 
      public void i_navigate_to_TheTestRoom_com() throws Throwable { 
        // Write code here that turns the phrase above into concrete actions 
        throw new PendingException(); 
      } 
      @When("^I navigate to Cucumber Tutorial page$") 
      public void i_navigate_to_Cucumber_Tutorial_page() throws Throwable { 
        // Write code here that turns the phrase above into concrete actions 
        throw new PendingException(); 
      } 
      @Then("^the page title should be visible$") 
      public void the_page_title_should_be_visible() throws Throwable { 
        // Write code here that turns the phrase above into concrete actions 
        throw new PendingException(); 
      } 

문제를 해결하는 방법에 대한 아이디어가 있으십니까?

+0

'myFirstStepDefinition' 클래스를 컴파일 했습니까? – alayor

+0

예. 했어요. javac를 사용하여 java 클래스를 컴파일하고 java 클래스 경로에 .class 파일을 포함 시켰습니다. "C : \ OutSystems \ HelloWorld \ step_definition \ *" 이 작업을 수행하는 배치 파일과 함께 격리 된 테스트 env가 있습니다. 문제 해결에 도움이됩니다. –

+0

전체 출력을 붙여 넣을 수 있습니까? –

답변

2

추측하지만 클래스 경로에는 두 번째 classpath 옵션에 "step_definition"부분이 없어야합니다. 계층 구조에서 두 개가 아닌 "step_definition"폴더가 하나만 있다고 가정하여이를 기반으로합니다.

+0

당신이 옳은 사람입니다. 클래스 경로에 루트 디렉토리 (... \ HelloWorld)를 추가하기 만하면됩니다. 나머지 경로 (... \ step_definition \)는 패키지 구조이며 거기에있을 수 없습니다. –