2017-08-14 1 views
2

'Given'を使わずに 'Scenario'と書いて、 'When'で直接始めることはできますか?BDD(行動)のシナリオは 'Given'なしで持つことができますか?

詳しい説明:

「背景」セクションでは、テストシナリオのために必要とどのような状態に既にあります。 したがって、私はただちに「When」を使用して開始し、いくつかのアクションを実行したかっただけです。

答えて

2

単純に、はい。この例に見られるように:

Feature: Testing Feature Without Given 

    Scenario: No given step 

     When we have no given step 
     Then our test should still work 

# coding: utf-8 

from behave import * 

@when("we have no given step") 
def step_impl(context): 

    pass 

@then("our test should still work") 
def step_impl(context): 

    pass 

Feature: Testing Feature Without Given # test.feature:1 

    Scenario: No given step   # test.feature:3 
    When we have no given step  # steps\step.py:5 
    Then our test should still work # steps\step.py:10 

1 feature passed, 0 failed, 0 skipped 
1 scenario passed, 0 failed, 0 skipped 
2 steps passed, 0 failed, 0 skipped, 0 undefined 
Took 0m0.002s 

しかし、これはベストプラクティスではないかもしれません。テストケースは、条件と期待される結果を意味します。背景はこの条件をカバーするものではなく、環境設定やWebアプリをテストするためのブラウザを開くような明白なステップのような広範な事前条件をカバーするものです。

関連する問題