1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
@issue
Feature: Issue #175: Scenario isn't marked as 'failed' when Background step fails
Scenario has currently status "skipped" when a background step fails.
Expected is that scenario status should be "failed".
Ensure that this is the case.
RELATED: features/background.feature
REUSE: Scenario from there (as copy).
. NOTE:
. Cucumber has a slightly different behaviour.
. When a background step fails the first scenario is marked as failed.
. But the remaining scenarios are marked as skipped.
.
. This can lead to problems when you have sporadic background step failures.
. For this reason, behave retries the background steps for each scenario.
.
. SEE ALSO:
. * https://github.com/cucumber/cucumber/blob/master/features/docs/gherkin/background.feature
@setup
Scenario: Feature Setup
Given a new working directory
And a file named "features/steps/background_steps.py" with:
"""
from behave import step
@step('{word} background step {outcome}')
def step_background_step_passes_or_fails(context, word, outcome):
if outcome == "fails":
assert False, "XFAIL: background step"
elif outcome == "passes":
pass
else:
message = "Unexpected outcome=%s. Use: passes, fails"
raise RuntimeError(message % outcome)
"""
And a file named "features/steps/passing_steps.py" with:
"""
from behave import step
@step('{word} step passes')
def step_passes(context, word):
pass
@step('{word} step fails')
def step_passes(context, word):
assert False, "XFAIL"
"""
Scenario: Failing Background Step causes all Scenarios to fail
Given a file named "features/example.background_step_fails.feature" with:
"""
Feature:
Background: B1
Given a background step passes
And a background step fails
And another background step passes
Scenario: S1
When a step passes
Scenario: S2
Then a step passes
And another step passes
"""
When I run "behave -f plain -T features/example.background_step_fails.feature"
Then it should fail with:
"""
0 scenarios passed, 2 failed, 0 skipped
2 steps passed, 2 failed, 5 skipped, 0 undefined
"""
And the command output should contain:
"""
Feature:
Background: B1
Scenario: S1
Given a background step passes ... passed
And a background step fails ... failed
Assertion Failed: XFAIL: background step
Scenario: S2
Given a background step passes ... passed
And a background step fails ... failed
Assertion Failed: XFAIL: background step
"""
|