2017-08-14 48 views

回答

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應用程序等明顯步驟。

相關問題