| 1 |
Feature: ScenarioOutline with tagged Examples |
| 2 |
|
| 3 |
As a tester |
| 4 |
I want to select (or exclude) a specific Examples table of a ScenarioOutline |
| 5 |
To run only the scenarios from the Examples table of interest. |
| 6 |
|
| 7 |
| SPECIFICATION: |
| 8 |
| Scenarios from a Examples table inherit the tags from |
| 9 |
| its ScenarioOutline tags and its Examples tags: |
| 10 |
| |
| 11 |
| scenario.tags = scenario_outline.tags + examples.tags |
| 12 |
| |
| 13 |
| Therefore, examples.tags can easily be used to select all scenarios |
| 14 |
| of this Examples table. |
| 15 |
| |
| 16 |
| NOTE: This allows to provide multiple Examples sections, |
| 17 |
| one for each stage of testing and/or one for each test team |
| 18 |
| (development testing, integration testing, system tests, ...). |
| 19 |
|
| 20 |
@setup |
| 21 |
Scenario: Feature Setup |
| 22 |
Given a new working directory |
| 23 |
And a file named "behave.ini" with: |
| 24 |
""" |
| 25 |
[behave] |
| 26 |
show_timestamps = false |
| 27 |
show_skipped = false |
| 28 |
""" |
| 29 |
And a file named "features/steps/steps.py" with: |
| 30 |
""" |
| 31 |
from behave import step |
| 32 |
|
| 33 |
@step('{word:w} step passes') |
| 34 |
def step_passes(context, word): |
| 35 |
pass |
| 36 |
""" |
| 37 |
And a file named "features/tagged_examples.feature" with: |
| 38 |
""" |
| 39 |
Feature: |
| 40 |
|
| 41 |
@zap |
| 42 |
Scenario Outline: |
| 43 |
Given <variant> step passes |
| 44 |
|
| 45 |
@foo |
| 46 |
Examples: Alice |
| 47 |
| variant | Comment | |
| 48 |
| a | First case | |
| 49 |
| another | Second case | |
| 50 |
|
| 51 |
@bar |
| 52 |
Examples: Bob |
| 53 |
| variant | Comment | |
| 54 |
| weird | First case | |
| 55 |
""" |
| 56 |
And a file named "behave.ini" with: |
| 57 |
""" |
| 58 |
[behave] |
| 59 |
show_skipped = false |
| 60 |
show_timings = false |
| 61 |
""" |
| 62 |
|
| 63 |
Scenario: Use all Examples (and Scenarios) |
| 64 |
When I run "behave -f plain features/tagged_examples.feature" |
| 65 |
Then it should pass with: |
| 66 |
""" |
| 67 |
1 feature passed, 0 failed, 0 skipped |
| 68 |
3 scenarios passed, 0 failed, 0 skipped |
| 69 |
""" |
| 70 |
|
| 71 |
Scenario: Select all Examples (and Scenarios) |
| 72 |
When I run "behave -f plain --tags=@zap features/tagged_examples.feature" |
| 73 |
Then it should pass with: |
| 74 |
""" |
| 75 |
1 feature passed, 0 failed, 0 skipped |
| 76 |
3 scenarios passed, 0 failed, 0 skipped |
| 77 |
""" |
| 78 |
|
| 79 |
Scenario: Select only first Examples table |
| 80 |
When I run "behave -f plain --tags=@foo features/tagged_examples.feature" |
| 81 |
Then it should pass with: |
| 82 |
""" |
| 83 |
1 feature passed, 0 failed, 0 skipped |
| 84 |
2 scenarios passed, 0 failed, 1 skipped |
| 85 |
""" |
| 86 |
And the command output should contain: |
| 87 |
""" |
| 88 |
Scenario Outline: -- @1.1 Alice |
| 89 |
Given a step passes ... passed |
| 90 |
|
| 91 |
Scenario Outline: -- @1.2 Alice |
| 92 |
Given another step passes ... passed |
| 93 |
""" |
| 94 |
But the command output should not contain: |
| 95 |
""" |
| 96 |
Scenario Outline: -- @2.1 Bob |
| 97 |
""" |
| 98 |
|
| 99 |
Scenario: Select only second Examples table |
| 100 |
When I run "behave -f plain --tags=@bar features/tagged_examples.feature" |
| 101 |
Then it should pass with: |
| 102 |
""" |
| 103 |
1 feature passed, 0 failed, 0 skipped |
| 104 |
1 scenario passed, 0 failed, 2 skipped |
| 105 |
""" |
| 106 |
And the command output should contain: |
| 107 |
""" |
| 108 |
Scenario Outline: -- @2.1 Bob |
| 109 |
Given weird step passes ... passed |
| 110 |
""" |
| 111 |
But the command output should not contain: |
| 112 |
""" |
| 113 |
Scenario Outline: -- @1.1 Alice |
| 114 |
Given a step passes ... passed |
| 115 |
|
| 116 |
Scenario Outline: -- @1.2 Alice |
| 117 |
Given another step passes ... passed |
| 118 |
""" |