Scenario in BDD(behave) can have without 'Given'? -
can write 'scenario' in behave without 'given' , directly start 'when' ?
more description:
'background' section in state requires test scenario. hence, wanted start directly 'when' , perform actions.
simply, yes. seen in example:
feature: testing feature without given scenario: no given step when have no given step our test should still work
# coding: utf-8 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 have no given step # steps\step.py:5 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
however, may not best practice. test case implies condition , expected result. background isn't meant cover condition, rather broader pre-conditions such environment setup or obvious steps opening browser test web app.
Comments
Post a Comment