| 1 |
@feature_request |
| 2 |
@issue |
| 3 |
Feature: Issue #228: Allow before_scenario to determine whether steps should be run. |
| 4 |
|
| 5 |
Allow before_scenario to call mark_skipped() and early out if the current |
| 6 |
scenario should be skipped. |
| 7 |
|
| 8 |
Scenario: Allow before_scenario to skip the current scenario |
| 9 |
|
| 10 |
Given a new working directory |
| 11 |
And a file named "features/steps/steps.py" with: |
| 12 |
""" |
| 13 |
from behave import step |
| 14 |
|
| 15 |
@step('a step passes') |
| 16 |
def step_passes(context): |
| 17 |
pass |
| 18 |
""" |
| 19 |
And a file named "features/environment.py" with |
| 20 |
""" |
| 21 |
def before_scenario(context, scenario): |
| 22 |
if scenario.name == 'Skip this scenario': |
| 23 |
scenario.skip() |
| 24 |
""" |
| 25 |
And a file named "features/issue228_example.feature" with |
| 26 |
""" |
| 27 |
Feature: |
| 28 |
Scenario: Skip this scenario |
| 29 |
Given I'm using an "undefined step" |
| 30 |
|
| 31 |
Scenario: Run this scenario |
| 32 |
Given a step passes |
| 33 |
""" |
| 34 |
When I run "behave -f plain features/issue228_example.feature" |
| 35 |
Then it should pass |
| 36 |
And the command output should contain: |
| 37 |
""" |
| 38 |
1 feature passed, 0 failed, 0 skipped |
| 39 |
1 scenario passed, 0 failed, 1 skipped |
| 40 |
1 step passed, 0 failed, 1 skipped, 0 undefined |
| 41 |
""" |