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
|
Feature: Ensure that BAD/SAD Use cases of Background are detected
To improve diagnostics when parser failures occur
As a test writer
I expect reasonable explanations what went wrong.
@setup
Scenario: Feature Setup
Given a new working directory
And a file named "features/steps/passing_steps.py" with
"""
from behave import step
@step('a step passes')
def step_passes(context):
pass
@step('a step passes with "{text}"')
def step_passes(context, text):
pass
"""
Scenario: Background with tags is not supported
Given a file named "features/syndrome.background_with_tags.feature" with
"""
Feature: Ensure this fails
@tags_are @not_supported @here
Background: Oops...
Given a step passes
Scenario: More...
Given a step passes
"""
When I run "behave -f plain -T features/syndrome.background_with_tags.feature"
Then it should fail with
"""
Failed to parse "{__WORKDIR__}/features/syndrome.background_with_tags.feature":
Parser failure in state taggable_statement, at line 4: "Background: Oops..."
REASON: Background does not support tags.
"""
Scenario: Background should not occur after a Scenario
Given a file named "features/syndrome.background_after_scenario.feature" with
"""
Feature: Ensure this fails1
Scenario: One...
Given a step passes
Background: Oops, too late (after Scenario)
When a step passes
"""
When I run "behave -f plain -T features/syndrome.background_after_scenario.feature"
Then it should fail with
"""
Failed to parse "{__WORKDIR__}/features/syndrome.background_after_scenario.feature":
Parser failure in state steps, at line 6: "Background: Oops, too late (after Scenario)"
REASON: Background may not occur after Scenario/ScenarioOutline.
"""
Scenario: Tagged Background should not occur after a Scenario
Given a file named "features/syndrome.tagged_background_after_scenario.feature" with
"""
Feature: Ensure this fails1
Scenario: One...
Given a step passes
@tags_are @not_supported @here
Background: Oops, too late (after Scenario)
When a step passes
"""
When I run "behave -f plain -T features/syndrome.tagged_background_after_scenario.feature"
Then it should fail with
"""
Parser failure in state taggable_statement, at line 7: "Background: Oops, too late (after Scenario)"
REASON: Background may not occur after Scenario/ScenarioOutline.
"""
Scenario: Background should not occur after a Scenario Outline
Given a file named "features/syndrome.background_after_scenario_outline.feature" with
"""
Feature: Ensure this fails3
Scenario Outline: Two...
Given a step passes with "<name>"
Examples:
| name |
| Alice |
Background: Oops, too late (after Scenario Outline)
When a step passes
"""
When I run "behave -f plain -T features/syndrome.background_after_scenario_outline.feature"
Then it should fail with
"""
Parser failure in state steps, at line 10: "Background: Oops, too late (after Scenario Outline)"
REASON: Background may not occur after Scenario/ScenarioOutline.
"""
Scenario: Tagged Background should not occur after a Scenario Outline
Given a file named "features/syndrome.background_after_scenario_outline.feature" with
"""
Feature: Ensure this fails4
Scenario Outline: Two...
Given a step passes with "<name>"
Examples:
| name |
| Alice |
@tags_are @not_supported @here
Background: Oops, too late (after Scenario Outline)
When a step passes
"""
When I run "behave -f plain -T features/syndrome.background_after_scenario_outline.feature"
Then it should fail with
"""
Parser failure in state taggable_statement, at line 11: "Background: Oops, too late (after Scenario Outline)"
REASON: Background may not occur after Scenario/ScenarioOutline.
"""
|