| 1 |
Feature: Ensure that BAD/SAD Use cases of Background are detected |
| 2 |
|
| 3 |
To improve diagnostics when parser failures occur |
| 4 |
As a test writer |
| 5 |
I expect reasonable explanations what went wrong. |
| 6 |
|
| 7 |
@setup |
| 8 |
Scenario: Feature Setup |
| 9 |
Given a new working directory |
| 10 |
And a file named "features/steps/passing_steps.py" with |
| 11 |
""" |
| 12 |
from behave import step |
| 13 |
|
| 14 |
@step('a step passes') |
| 15 |
def step_passes(context): |
| 16 |
pass |
| 17 |
|
| 18 |
@step('a step passes with "{text}"') |
| 19 |
def step_passes(context, text): |
| 20 |
pass |
| 21 |
""" |
| 22 |
|
| 23 |
|
| 24 |
Scenario: Background with tags is not supported |
| 25 |
Given a file named "features/syndrome.background_with_tags.feature" with |
| 26 |
""" |
| 27 |
Feature: Ensure this fails |
| 28 |
|
| 29 |
@tags_are @not_supported @here |
| 30 |
Background: Oops... |
| 31 |
Given a step passes |
| 32 |
|
| 33 |
Scenario: More... |
| 34 |
Given a step passes |
| 35 |
""" |
| 36 |
When I run "behave -f plain -T features/syndrome.background_with_tags.feature" |
| 37 |
Then it should fail with |
| 38 |
""" |
| 39 |
Failed to parse "{__WORKDIR__}/features/syndrome.background_with_tags.feature": |
| 40 |
Parser failure in state taggable_statement, at line 4: "Background: Oops..." |
| 41 |
REASON: Background does not support tags. |
| 42 |
""" |
| 43 |
|
| 44 |
|
| 45 |
Scenario: Background should not occur after a Scenario |
| 46 |
Given a file named "features/syndrome.background_after_scenario.feature" with |
| 47 |
""" |
| 48 |
Feature: Ensure this fails1 |
| 49 |
|
| 50 |
Scenario: One... |
| 51 |
Given a step passes |
| 52 |
|
| 53 |
Background: Oops, too late (after Scenario) |
| 54 |
When a step passes |
| 55 |
""" |
| 56 |
When I run "behave -f plain -T features/syndrome.background_after_scenario.feature" |
| 57 |
Then it should fail with |
| 58 |
""" |
| 59 |
Failed to parse "{__WORKDIR__}/features/syndrome.background_after_scenario.feature": |
| 60 |
Parser failure in state steps, at line 6: "Background: Oops, too late (after Scenario)" |
| 61 |
REASON: Background may not occur after Scenario/ScenarioOutline. |
| 62 |
""" |
| 63 |
|
| 64 |
|
| 65 |
Scenario: Tagged Background should not occur after a Scenario |
| 66 |
Given a file named "features/syndrome.tagged_background_after_scenario.feature" with |
| 67 |
""" |
| 68 |
Feature: Ensure this fails1 |
| 69 |
|
| 70 |
Scenario: One... |
| 71 |
Given a step passes |
| 72 |
|
| 73 |
@tags_are @not_supported @here |
| 74 |
Background: Oops, too late (after Scenario) |
| 75 |
When a step passes |
| 76 |
""" |
| 77 |
When I run "behave -f plain -T features/syndrome.tagged_background_after_scenario.feature" |
| 78 |
Then it should fail with |
| 79 |
""" |
| 80 |
Parser failure in state taggable_statement, at line 7: "Background: Oops, too late (after Scenario)" |
| 81 |
REASON: Background may not occur after Scenario/ScenarioOutline. |
| 82 |
""" |
| 83 |
|
| 84 |
|
| 85 |
Scenario: Background should not occur after a Scenario Outline |
| 86 |
Given a file named "features/syndrome.background_after_scenario_outline.feature" with |
| 87 |
""" |
| 88 |
Feature: Ensure this fails3 |
| 89 |
|
| 90 |
Scenario Outline: Two... |
| 91 |
Given a step passes with "<name>" |
| 92 |
|
| 93 |
Examples: |
| 94 |
| name | |
| 95 |
| Alice | |
| 96 |
|
| 97 |
Background: Oops, too late (after Scenario Outline) |
| 98 |
When a step passes |
| 99 |
""" |
| 100 |
When I run "behave -f plain -T features/syndrome.background_after_scenario_outline.feature" |
| 101 |
Then it should fail with |
| 102 |
""" |
| 103 |
Parser failure in state steps, at line 10: "Background: Oops, too late (after Scenario Outline)" |
| 104 |
REASON: Background may not occur after Scenario/ScenarioOutline. |
| 105 |
""" |
| 106 |
|
| 107 |
|
| 108 |
Scenario: Tagged Background should not occur after a Scenario Outline |
| 109 |
Given a file named "features/syndrome.background_after_scenario_outline.feature" with |
| 110 |
""" |
| 111 |
Feature: Ensure this fails4 |
| 112 |
|
| 113 |
Scenario Outline: Two... |
| 114 |
Given a step passes with "<name>" |
| 115 |
|
| 116 |
Examples: |
| 117 |
| name | |
| 118 |
| Alice | |
| 119 |
|
| 120 |
@tags_are @not_supported @here |
| 121 |
Background: Oops, too late (after Scenario Outline) |
| 122 |
When a step passes |
| 123 |
""" |
| 124 |
When I run "behave -f plain -T features/syndrome.background_after_scenario_outline.feature" |
| 125 |
Then it should fail with |
| 126 |
""" |
| 127 |
Parser failure in state taggable_statement, at line 11: "Background: Oops, too late (after Scenario Outline)" |
| 128 |
REASON: Background may not occur after Scenario/ScenarioOutline. |
| 129 |
""" |