| 1 |
@sequential |
| 2 |
Feature: Select scenarios by using tags |
| 3 |
|
| 4 |
As a tester |
| 5 |
I want to select a subset of all scenarios by using tags |
| 6 |
(for selecting/including them or excluding them) |
| 7 |
So that I run only a subset of scenarios. |
| 8 |
|
| 9 |
. RELATED: |
| 10 |
. * runner.tag_logic.feature |
| 11 |
|
| 12 |
|
| 13 |
@setup |
| 14 |
Scenario: Feature Setup |
| 15 |
Given a new working directory |
| 16 |
And a file named "behave.ini" with: |
| 17 |
""" |
| 18 |
[behave] |
| 19 |
default_format = plain |
| 20 |
show_skipped = false |
| 21 |
show_timings = false |
| 22 |
""" |
| 23 |
And a file named "features/steps/steps.py" with: |
| 24 |
""" |
| 25 |
from behave import step |
| 26 |
|
| 27 |
@step('{word:w} step passes') |
| 28 |
def step_passes(context, word): |
| 29 |
pass |
| 30 |
""" |
| 31 |
And a file named "features/alice.feature" with: |
| 32 |
""" |
| 33 |
Feature: Alice |
| 34 |
@foo |
| 35 |
Scenario: Alice in Wonderland |
| 36 |
Given a step passes |
| 37 |
|
| 38 |
@foo @bar |
| 39 |
Scenario: Alice in Florida |
| 40 |
When hotter step passes |
| 41 |
|
| 42 |
@bar |
| 43 |
Scenario: Alice in Antarctica |
| 44 |
Then colder step passes |
| 45 |
""" |
| 46 |
And a file named "features/bob.feature" with: |
| 47 |
""" |
| 48 |
Feature: Bob |
| 49 |
@bar |
| 50 |
Scenario: Bob in Berlin |
| 51 |
Given beautiful step passes |
| 52 |
|
| 53 |
@foo |
| 54 |
Scenario: Bob in Florida |
| 55 |
When freaky step passes |
| 56 |
|
| 57 |
Scenario: Alice and Bob |
| 58 |
Then another step passes |
| 59 |
""" |
| 60 |
|
| 61 |
|
| 62 |
Scenario: Select scenarios with tag=@foo (inclusive) |
| 63 |
|
| 64 |
TAG-LOGIC: @foo |
| 65 |
|
| 66 |
When I run "behave -f plain --tags=foo --no-skipped --no-timings features/" |
| 67 |
Then it should pass with: |
| 68 |
""" |
| 69 |
2 features passed, 0 failed, 0 skipped |
| 70 |
3 scenarios passed, 0 failed, 3 skipped |
| 71 |
3 steps passed, 0 failed, 3 skipped, 0 undefined |
| 72 |
""" |
| 73 |
And the command output should contain: |
| 74 |
""" |
| 75 |
Feature: Alice |
| 76 |
Scenario: Alice in Wonderland |
| 77 |
Given a step passes ... passed |
| 78 |
|
| 79 |
Scenario: Alice in Florida |
| 80 |
When hotter step passes ... passed |
| 81 |
|
| 82 |
Feature: Bob |
| 83 |
Scenario: Bob in Florida |
| 84 |
When freaky step passes ... passed |
| 85 |
""" |
| 86 |
|
| 87 |
Scenario: Select scenarios without tag=@foo (exclusive) |
| 88 |
|
| 89 |
TAG-LOGIC: not @foo |
| 90 |
|
| 91 |
Use '-' (minus-sign) or '~' (tilde) in front of the tag-name |
| 92 |
to negate the tag-selection (excluding tags mode). |
| 93 |
|
| 94 |
When I run "behave --tags=~@foo features/" |
| 95 |
Then it should pass with: |
| 96 |
""" |
| 97 |
2 features passed, 0 failed, 0 skipped |
| 98 |
3 scenarios passed, 0 failed, 3 skipped |
| 99 |
3 steps passed, 0 failed, 3 skipped, 0 undefined |
| 100 |
""" |
| 101 |
And the command output should contain: |
| 102 |
""" |
| 103 |
Feature: Alice |
| 104 |
Scenario: Alice in Antarctica |
| 105 |
Then colder step passes ... passed |
| 106 |
|
| 107 |
Feature: Bob |
| 108 |
Scenario: Bob in Berlin |
| 109 |
Given beautiful step passes ... passed |
| 110 |
|
| 111 |
Scenario: Alice and Bob |
| 112 |
Then another step passes ... passed |
| 113 |
""" |
| 114 |
|
| 115 |
Scenario: Select scenarios with @foo and @bar tags (both) |
| 116 |
|
| 117 |
TAG-LOGIC: @foo and @bar |
| 118 |
|
| 119 |
When I run "behave --tags=@foo --tags=@bar features/" |
| 120 |
Then it should pass with: |
| 121 |
""" |
| 122 |
1 feature passed, 0 failed, 1 skipped |
| 123 |
1 scenario passed, 0 failed, 5 skipped |
| 124 |
1 step passed, 0 failed, 5 skipped, 0 undefined |
| 125 |
""" |
| 126 |
And the command output should contain: |
| 127 |
""" |
| 128 |
Feature: Alice |
| 129 |
Scenario: Alice in Florida |
| 130 |
When hotter step passes |
| 131 |
""" |
| 132 |
And note that "only scenario 'Alice in Florida' has both tags" |
| 133 |
|
| 134 |
|
| 135 |
Scenario: Select scenarios without @foo tag and without @bar tag |
| 136 |
|
| 137 |
TAG-LOGIC: not @foo and not @bar |
| 138 |
|
| 139 |
When I run "behave --tags=-@foo --tags=-@bar features/" |
| 140 |
Then it should pass with: |
| 141 |
""" |
| 142 |
1 feature passed, 0 failed, 1 skipped |
| 143 |
1 scenario passed, 0 failed, 5 skipped |
| 144 |
1 step passed, 0 failed, 5 skipped, 0 undefined |
| 145 |
""" |
| 146 |
And the command output should contain: |
| 147 |
""" |
| 148 |
Feature: Bob |
| 149 |
Scenario: Alice and Bob |
| 150 |
Then another step passes |
| 151 |
""" |
| 152 |
And note that "only scenario 'Alice and Bob' has neither tag" |
| 153 |
|
| 154 |
|
| 155 |
Scenario: Select scenarios with @foo tag, but exclude with @bar tag |
| 156 |
|
| 157 |
TAG-LOGIC: @foo and not @bar |
| 158 |
|
| 159 |
When I run "behave --tags=@foo --tags=-@bar features/" |
| 160 |
Then it should pass with: |
| 161 |
""" |
| 162 |
2 features passed, 0 failed, 0 skipped |
| 163 |
2 scenarios passed, 0 failed, 4 skipped |
| 164 |
2 steps passed, 0 failed, 4 skipped, 0 undefined |
| 165 |
""" |
| 166 |
And the command output should contain: |
| 167 |
""" |
| 168 |
Feature: Alice |
| 169 |
Scenario: Alice in Wonderland |
| 170 |
Given a step passes ... passed |
| 171 |
|
| 172 |
Feature: Bob |
| 173 |
Scenario: Bob in Florida |
| 174 |
When freaky step passes ... passed |
| 175 |
""" |
| 176 |
But note that "'Alice in Florida' is excluded because it has also @bar" |
| 177 |
|
| 178 |
|
| 179 |
Scenario: Select scenarios with @bar tag, but exclude with @foo tag |
| 180 |
|
| 181 |
TAG-LOGIC: not @foo and @bar |
| 182 |
|
| 183 |
When I run "behave --tags=-@foo --tags=@bar features/" |
| 184 |
Then it should pass with: |
| 185 |
""" |
| 186 |
2 features passed, 0 failed, 0 skipped |
| 187 |
2 scenarios passed, 0 failed, 4 skipped |
| 188 |
2 steps passed, 0 failed, 4 skipped, 0 undefined |
| 189 |
""" |
| 190 |
And the command output should contain: |
| 191 |
""" |
| 192 |
Feature: Alice |
| 193 |
Scenario: Alice in Antarctica |
| 194 |
Then colder step passes ... passed |
| 195 |
|
| 196 |
Feature: Bob |
| 197 |
Scenario: Bob in Berlin |
| 198 |
Given beautiful step passes ... passed |
| 199 |
""" |
| 200 |
But note that "'Alice in Florida' is excluded because it has also @bar" |
| 201 |
|
| 202 |
|
| 203 |
Scenario: Select scenarios with tag=@foo in dry-run mode (inclusive) |
| 204 |
|
| 205 |
Ensure that tag-selection works also in dry-run mode. |
| 206 |
|
| 207 |
When I run "behave --tags=@foo --dry-run features/" |
| 208 |
Then it should pass with: |
| 209 |
""" |
| 210 |
0 features passed, 0 failed, 0 skipped, 2 untested |
| 211 |
0 scenarios passed, 0 failed, 3 skipped, 3 untested |
| 212 |
0 steps passed, 0 failed, 3 skipped, 0 undefined, 3 untested |
| 213 |
""" |
| 214 |
And the command output should contain: |
| 215 |
""" |
| 216 |
Feature: Alice |
| 217 |
Scenario: Alice in Wonderland |
| 218 |
Given a step passes ... untested |
| 219 |
Scenario: Alice in Florida |
| 220 |
When hotter step passes ... untested |
| 221 |
|
| 222 |
Feature: Bob |
| 223 |
Scenario: Bob in Florida |
| 224 |
When freaky step passes ... untested |
| 225 |
""" |