2016-07-14 7 views
0

私はAppiumを初めて使用しており、Background:は、Appiumの.featureファイルで何をするのか分かりません。誰か私にそれを説明できますか?appium .featureファイルの 'Background'アノテーションは何を意味しますか?

Background:の下に置かれたテストステップは、1つのシナリオの終了後毎回実行されます。

+0

ちょうどそれがキュウリの特徴であるようにAppiumとは関係がないという事実を強調する。 –

+0

'Background'ブロックの各ステップは、各シナリオの現在の' * .feature'ファイルの前に実行されます –

答えて

0

フィーチャーファイルのバックグラウンドセクションでは、ファイル内のすべてのシナリオに共通のステップセットを指定できます。したがって、シナリオごとにこれらのステップを何度も繰り返す必要はなく、バックグラウンド 要素に移動することができます。これを行うに

利点は以下のとおりです。

  • あなたはこれらの手順を変更する必要がある場合は、あなただけの 一箇所でそれらを変更する必要があります。
  • 個々のシナリオを読んでいるときは、固有のものである に焦点を当て、そのシナリオについて重要なことができるように、これらのステップの重要性はバックグラウンドに消えます。あなたが最初の数ステップは、各シナリオで自分自身を繰り返していることがわかります上記2つのシナリオから

    Scenario: Change PIN successfully 
        Given I have been issued a new card 
        And I insert the card, entering the correct PIN 
        When I choose "Change PIN" from the menu 
        And I change the PIN to 9876 
        Then the system should remember my PIN is now 9876 
    
    Scenario: Try to change PIN to the same as before 
        Given I have been issued a new card 
        And I insert the card, entering the correct PIN 
        When I choose "Change PIN" from the menu 
        And I try to change the PIN to the original PIN number 
        Then I should see a warning message 
        And the system should not have changed my PIN 
    

は、例えば、以下の2つのシナリオを検討してください。だから私たちができることは、それらをバックグラウンドに移動することです。そして、それらは自動的に各シナリオの始めに実行されます。

Background: 
    Given I have been issued a new card 
    And I insert the card, entering the correct PIN 
    And I choose "Change PIN" from the menu 

Scenario: Change PIN successfully 
    When I change the PIN to 9876 
    Then the system should remember my PIN is now 9876 

Scenario: Try to change PIN to the same as before 
    When I try to change the PIN to the original PIN number 
    Then I should see a warning message 
    And the system should not have changed my PIN 
+1

Thanks a lott @Eugene S – girish

関連する問題