Debian Codegraph @

issue.features/issue0175.feature

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