| 1 |
@issue |
| 2 |
Feature: Issue #145: before_feature/after_feature should not be skipped |
| 3 |
|
| 4 |
Hooks before_feature(), after_feature() (and before_step()) are skipped |
| 5 |
if --tags options select feature tag and scenario tag. |
| 6 |
|
| 7 |
SEE ALSO: https://github.com/cucumber/cucumber/wiki/Tags |
| 8 |
|
| 9 |
@setup |
| 10 |
Scenario: Setup |
| 11 |
Given a new working directory |
| 12 |
And a file named "features/steps/steps.py" with: |
| 13 |
""" |
| 14 |
from behave import step |
| 15 |
|
| 16 |
@step('a step passes') |
| 17 |
def step_passes(context): |
| 18 |
pass |
| 19 |
""" |
| 20 |
And a file named "features/issue0145_example.feature" with: |
| 21 |
""" |
| 22 |
@feature |
| 23 |
Feature: Feature-145 |
| 24 |
|
| 25 |
@scenario |
| 26 |
Scenario: Scenario-145 |
| 27 |
Given a step passes |
| 28 |
When a step passes |
| 29 |
Then a step passes |
| 30 |
""" |
| 31 |
And a file named "features/environment.py" with: |
| 32 |
""" |
| 33 |
from __future__ import print_function |
| 34 |
|
| 35 |
def before_feature(context, feature): |
| 36 |
print("hooks.before_feature: %s called." % feature.name) |
| 37 |
|
| 38 |
def after_feature(context, feature): |
| 39 |
print("hooks.after_feature: %s called." % feature.name) |
| 40 |
""" |
| 41 |
|
| 42 |
Scenario: Select only @scenario tag |
| 43 |
When I run "behave -f plain -T --tags=@scenario features/issue0145_example.feature" |
| 44 |
Then it should pass with: |
| 45 |
""" |
| 46 |
1 feature passed, 0 failed, 0 skipped |
| 47 |
1 scenario passed, 0 failed, 0 skipped |
| 48 |
3 steps passed, 0 failed, 0 skipped, 0 undefined |
| 49 |
""" |
| 50 |
And the behave hook "before_feature" was called |
| 51 |
And the behave hook "after_feature" was called |
| 52 |
|
| 53 |
Scenario: Select @feature tag and @scenario tag (logical-and, fails if not fixed) |
| 54 |
When I run "behave -f plain -T --tags=@feature --tags=@scenario features/issue0145_example.feature" |
| 55 |
Then it should pass with: |
| 56 |
""" |
| 57 |
1 feature passed, 0 failed, 0 skipped |
| 58 |
1 scenario passed, 0 failed, 0 skipped |
| 59 |
3 steps passed, 0 failed, 0 skipped, 0 undefined |
| 60 |
""" |
| 61 |
And the behave hook "before_feature" was called |
| 62 |
And the behave hook "after_feature" was called |
| 63 |
|