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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
Feature: Runner should continue after a failed step
As a tester or test writer
I want that the remaining scenario steps are executed even when a step fails
So that I see all remaining failures.
. NOTES:
. This may cause a number of correlated failures in the remaining steps.
. Therefore the default behavior of the runner is to skip the
. remaining scenario steps after a failure has occurred.
.
. RELATED TO: CR #299 (duplicated: #314)
@setup
Scenario: Test Setup
Given a new working directory
And a file named "features/steps/steps.py" with:
"""
from behave import step
import sys
@step('{word:w} step passes')
def step_passes(context, word):
pass
@step('{word:w} step fails')
def step_fails(context, word):
assert False, "XFAIL (in: %s step)" % word
"""
And a file named "features/alice.feature" with:
"""
Feature: Alice
Scenario: Passing
Given first step passes
When second step passes
Then third step passes
Scenario: Fails in second step
Given a step passes
When second step fails
Then another step passes
@runner.continue_after_failed_step
Scenario: Fails in first and third step
Given first step fails
When second step passes
Then third step fails
"""
Scenario: Runner continues after failed step in all scenarios
Given a file named "features/environment.py" with:
"""
from behave.model import Scenario
def before_all(context):
userdata = context.config.userdata
continue_after_failed = userdata.getbool("runner.continue_after_failed_step", False)
Scenario.continue_after_failed_step = continue_after_failed
"""
And a file named "behave.ini" with:
"""
[behave]
show_timings = false
[behave.userdata]
runner.continue_after_failed_step = true
"""
When I run "behave -f plain features/alice.feature"
Then it should fail with:
"""
Failing scenarios:
features/alice.feature:7 Fails in second step
features/alice.feature:13 Fails in first and third step
0 features passed, 1 failed, 0 skipped
1 scenario passed, 2 failed, 0 skipped
6 steps passed, 3 failed, 0 skipped, 0 undefined
"""
And the command output should contain:
"""
Scenario: Fails in second step
Given a step passes ... passed
When second step fails ... failed
Assertion Failed: XFAIL (in: second step)
Then another step passes ... passed
Scenario: Fails in first and third step
Given first step fails ... failed
Assertion Failed: XFAIL (in: first step)
When second step passes ... passed
Then third step fails ... failed
Assertion Failed: XFAIL (in: third step)
"""
But note that "step execution continues after failed step(s)"
And note that "no steps are skipped"
Scenario: Runner continues after failed step in some scenarios
Enable this feature only on tagged scenarios (or features).
Given a file named "features/environment.py" with:
"""
def before_scenario(context, scenario):
if "runner.continue_after_failed_step" in scenario.effective_tags:
scenario.continue_after_failed_step = True
"""
When I run "behave -f plain -T features/alice.feature"
Then it should fail with:
"""
Failing scenarios:
features/alice.feature:7 Fails in second step
features/alice.feature:13 Fails in first and third step
0 features passed, 1 failed, 0 skipped
1 scenario passed, 2 failed, 0 skipped
5 steps passed, 3 failed, 1 skipped, 0 undefined
"""
And the command output should contain:
"""
Scenario: Fails in second step
Given a step passes ... passed
When second step fails ... failed
Assertion Failed: XFAIL (in: second step)
Scenario: Fails in first and third step
Given first step fails ... failed
Assertion Failed: XFAIL (in: first step)
When second step passes ... passed
Then third step fails ... failed
Assertion Failed: XFAIL (in: third step)
"""
But note that "step execution continues after failed step in tagged scenario only"
And note that "some steps are skipped (in 2nd, untagged scenario)"
|