2017-11-16 13 views
0

내 기능 파일에 추가 한 단계에 대한 단계 정의를 작성하려고했습니다. 내 VS Code.But에 Cucumber Full Support가 설치되어 있어도 단계를 작성할 수 없습니다. 누군가 이걸 해결하도록 도와 줄 수 있니? Visual Studio 코드에서 단계 정의를 작성하는 방법 코드

PFB에게 예제 코드

는 더 명확 내가

And event list has the following IDs 
    | offlineEventId | 
    | 1    | 
    | 2    | 

And event list has the following IDS and desc 
    | offlineId | offlineDescription | 
    | 1   | abc     | 
    | 2   | xyz     | 

같은 두 단계와 기능 파일을 가지고 해결하기 위해 도와주세요 나는 모두

this.Then(/^event list has the following offline IDs/, function(expectedEventTable){ 

}); 



this.Then(/^event list has the following offline event IDs and desc/, function(expectedEventTable) { 

}); 


But both the steps in feature file is pointing to the first method in step definition 

위한 단계 defns를 작성했는지 확인하기 이

답변

0

단계 정의에 몇 가지 실수가있는 것 같습니다. 먼저 이름은 $ /로 끝나야합니다. 둘째, 이름이 기능 파일의 이름과 일치하지 않습니다. 단계 정의의 이름에 '오프라인'이 있지만 '오프라인'이 기능 파일에 표시되지 않습니다. 나는 두 단계 모두 동일한 단계 정의를 실행하는 이유를 알지 못한다. 내 추측은 공유하지 않은 코드의 어딘가에 오류가 있다는 것입니다. 그래서, Test.feature을 다음과 같은 기능 파일을 작업 한 :

Feature: Test 

Scenario: Test Cucumber is working 
    Given I want it to work 
    When I Run this feature 
    Then I should see the right console log messages 
    And event list has the following IDs 
    | offlineEventId | 
    | 1    | 
    | 2    | 
    And event list has the following IDS and desc 
    | offlineId | offlineDescription | 
    | 1   | abc     | 
    | 2   | xyz     | 

및 단계는 단계 정의에서 파일 Test.steps.ts 있습니다

다음과 같은 출력 제공
module.exports = function() { 

    this.Given(/^I want it to work$/, function(){ 
    console.log('Given step'); 
    }); 

    this.When(/^I Run this feature$/, function(){ 
    console.log('When step'); 
    }); 

    this.Then(/^I should see the right console log messages$/, function(){ 
    console.log('Then step 1'); 
    }); 

    this.Then(/^event list has the following IDs$/, function(expectedEventTable){ 
    console.log('Then step 2'); 
    }); 

    this.Then(/^event list has the following IDS and desc$/, function(expectedEventTable) { 
    console.log('Then step 3'); 
    }); 
}; 

:

Feature: Test 

    Scenario: Test Cucumber is working 
Given step 
    √ Given I want it to work 
When step 
    √ When I Run this feature 
Then step 1 
    √ Then I should see the right console log messages 
Then step 2 
    √ And event list has the following IDs 
     | offlineEventId | 
     | 1    | 
     | 2    | 
Then step 3 
    √ And event list has the following IDS and desc 
     | offlineId | offlineDescription | 
     | 1   | abc    | 
     | 2   | xyz    | 

1 scenario (1 passed) 
5 steps (5 passed) 
+0

나는 이것을 시도해 보았습니다. 그러나 첫 번째 방법이 쓰여지는 것 같습니다 .2 번째 피쳐 라인의 스텝 정의가 먼저 쓰여지면 적절한 것을 취하지 않을 것입니다. 그들은 연속적인 순서로 가져 가야합니까? 단계 정의 직접 기능 파일에서? – RRR

+0

단계는 전체 문자열과 패턴이 일치해야하므로 필자의 기능 파일이 일치하지 않는 단계를 호출하는 방법을 알지 못합니다. 내가 생각할 수있는 유일한 점은 실제로 실제로 보이는 단계를 실제로 실행하고있는 단계를 호출하는 기능 파일이 아니라는 것입니다. – Iain

+0

Visual Studio 코드에서 왜 그렇게 행동하는지 잘 모르겠습니다. intellij 아이디어가 좋았습니다. 정확한 단계를 호출 할 때까지 단계 정의에서 코드를 조정했습니다. – RRR