2017-07-13 5 views
0

私はキュウリのシナリオを変えなければなりません。キュウリの重複した手順を管理するにはどうすればよいですか?

@tag 
Feature: Click on link 
    The webdriver should be able to click on link 

    @tag1 
    Scenario: Title of your scenario 
    Given I am in "http://suvian.in/selenium/1.1link.html" 
    When I clcik on the link 
    Then It navigates to the "http://suvian.in/selenium/1.1link_validate.html" 
    And I can see the message "Link Successfully clicked" 

2つ目は、(SecondTask Scenario)である:最初の1(FirstTask Scenario)がある

@tag 
Feature: Fill the input text 
    The webdriver should be able to fill an input in a form 

    @tag1 
    Scenario: Title of your scenario 
    Given I am in "http://suvian.in/selenium/1.2text_field.html" 
    When I enter "Salman" in the input 
    And I click on "Next Task" 
    Then It navigates to the "http://suvian.in/selenium/1.3age_plceholder.html" 

私は2番目のシナリオを実行すると、JVM-キュウリは私に以下を与える:

@tag1 
    Scenario: Title of your scenario            # D:/Workspace/IgniteTask/src/features/SecondTask.feature:6 
    Given I am in "http://suvian.in/selenium/1.2text_field.html"    # FirstTask_Step.i_am_in(String) 
    When I enter "Salman" in the input 
    And I click on "Next Task" 
    Then It navigates to the "http://suvian.in/selenium/1.3age_plceholder.html" # FirstTask_Step.it_navigates_to_the(String) 

1 Scenarios (1 undefined) 
4 Steps (1 skipped, 2 undefined, 1 passed) 
0m11.038s 


You can implement missing steps with the snippets below: 

@When("^I enter \"([^\"]*)\" in the input$") 
public void i_enter_in_the_input(String arg1) throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@When("^I click on \"([^\"]*)\"$") 
public void i_click_on(String arg1) throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

部分:

Given I am in "http://suvian.in/selenium/1.2text_field.html"    # FirstTask_Step.i_am_in(String) 
    Then It navigates to the "http://suvian.in/selenium/1.3age_plceholder.html" # FirstTask_Step.it_navigates_to_the(String) 

つまり、これらの2つのステップでは、firstTaskから手順が実行されます。

私には意味がありません。すべてのシナリオには独自の手順が必要です。ここではsceondTaskのシナリオは最初の1つのステップを使用していますか?

+0

これはキュウリフレームワークの基本機能です。ストーリー・ステップのステップ定義を複数のシナリオに再利用することができます。なぜあなたは2番目のシナリオに行くときに同じステップのステップ定義を書き直したいのですか? – Murthi

答えて

0

毎回各シナリオで、cucumberoptionsに記載されている「グルー」オプションに含まれるWhen Then ...アノテーションを含むすべてのクラスがロードされます。

各シナリオステップで使用するステップ定義は、の正規表現をWhen Then ...アノテーションの値とシナリオステップテキストの値で一致させることでを取得します。

特定のステップ定義クラスと機能ファイルの間にはマッピングがありません。したがって、異なる動作が必要な場合は、ステップのテキストを変更し、対応するステップ定義メソッドを書き留める必要があります。

前と後のフックに同じロジックが適用されます。指定されたグルーオプションに含まれているクラスからピックアップされます。

関連する問題