2017-11-16 8 views
0

フィーチャファイルに追加したステップのステップ定義を作成しようとしていました.Cucumber Full SupportがVS Code.Butにインストールされていますが、まだステップを作成できません誰かが私にこれを解決する手助けをすることができますか?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     | 

のような2つの段階で機能ファイルを持っていると私は

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

私はなぜそれがビジュアルスタジオコードで動作しているのかわかりません。intellijのアイデアでうまくいきました。正しいステップを呼び出すまで、ステップ定義のコードを調整しました – RRR

関連する問題