| 1 |
@issue |
| 2 |
@change_request |
| 3 |
Feature: Issue #385 -- before_scenario called too late |
| 4 |
|
| 5 |
. RATIONALE: |
| 6 |
. Due to: |
| 7 |
. |
| 8 |
. * skip scenario/feature support in before_scenario (and before_feature) hooks |
| 9 |
. * active-tags |
| 10 |
. |
| 11 |
. formatters are now called to early (for before feature/scenario functionality). |
| 12 |
. Formatters should be called after the before-hooks are processed. |
| 13 |
. |
| 14 |
. NOTES: |
| 15 |
. * Test uses show_skipped=false to ensure that at least the |
| 16 |
. scenario/feature title is shown with plain formatter. |
| 17 |
|
| 18 |
@setup |
| 19 |
Scenario: |
| 20 |
Given a new working directory |
| 21 |
And a file named "features/steps/pass_steps.py" with: |
| 22 |
""" |
| 23 |
from behave import step |
| 24 |
|
| 25 |
@step('{word:w} step passes') |
| 26 |
def step_passes(context, word): |
| 27 |
pass |
| 28 |
""" |
| 29 |
And a file named "features/environment.py" with: |
| 30 |
""" |
| 31 |
from __future__ import print_function |
| 32 |
|
| 33 |
def before_feature(context, feature): |
| 34 |
if "skip" in feature.tags: |
| 35 |
print("SKIP-FEATURE: %s" % feature.name) |
| 36 |
feature.mark_skipped() |
| 37 |
|
| 38 |
def before_scenario(context, scenario): |
| 39 |
if "skip" in scenario.tags: |
| 40 |
print("SKIP-SCENARIO: %s" % scenario.name) |
| 41 |
scenario.mark_skipped() |
| 42 |
""" |
| 43 |
And a file named "behave.ini" with: |
| 44 |
""" |
| 45 |
[behave] |
| 46 |
show_skipped = false |
| 47 |
""" |
| 48 |
|
| 49 |
Scenario: Formatter is not called with skip in before_scenario hook |
| 50 |
Given a file named "features/alice.feature" with: |
| 51 |
""" |
| 52 |
Feature: Alice |
| 53 |
|
| 54 |
@skip |
| 55 |
Scenario: Alice and Bob |
| 56 |
Given a step passes |
| 57 |
|
| 58 |
Scenario: Alice in China |
| 59 |
When another step passes |
| 60 |
""" |
| 61 |
When I run "behave -f plain features/alice.feature" |
| 62 |
Then it should pass with: |
| 63 |
""" |
| 64 |
1 scenario passed, 0 failed, 1 skipped |
| 65 |
""" |
| 66 |
And the command output should contain: |
| 67 |
""" |
| 68 |
SKIP-SCENARIO: Alice and Bob |
| 69 |
|
| 70 |
Scenario: Alice in China |
| 71 |
When another step passes ... passed |
| 72 |
""" |
| 73 |
But the command output should not contain: |
| 74 |
""" |
| 75 |
Scenario: Alice and Bob |
| 76 |
SKIP-FEATURE: Alice and Bob |
| 77 |
""" |
| 78 |
And the command output should not contain "Scenario: Alice and Bob" |
| 79 |
|
| 80 |
|
| 81 |
Scenario: Formatter is not called with skip in before_feature hook |
| 82 |
Given a file named "features/bob.feature" with: |
| 83 |
""" |
| 84 |
@skip |
| 85 |
Feature: Bob |
| 86 |
|
| 87 |
Scenario: Bob and Alice |
| 88 |
Given a step passes |
| 89 |
|
| 90 |
Scenario: Bob in China |
| 91 |
When another step passes |
| 92 |
""" |
| 93 |
When I run "behave -f plain features/bob.feature" |
| 94 |
Then it should pass with: |
| 95 |
""" |
| 96 |
SKIP-FEATURE: Bob |
| 97 |
|
| 98 |
0 features passed, 0 failed, 1 skipped |
| 99 |
0 scenarios passed, 0 failed, 2 skipped |
| 100 |
""" |
| 101 |
But the command output should not contain: |
| 102 |
""" |
| 103 |
Feature: Bob |
| 104 |
SKIP-FEATURE: Bob |
| 105 |
""" |
| 106 |
And the command output should not contain "Feature: Bob" |
| 107 |
And the command output should not contain "Scenario: Bob and Alice" |
| 108 |
And the command output should not contain "Scenario: Bob in China" |
| 109 |
And note that "all scenarios of the feature are also skipped" |