| 1 |
@sequential |
| 2 |
Feature: Feature Listfile (List of feature filenames/directories) |
| 3 |
|
| 4 |
As a tester |
| 5 |
I want to run a list of features together |
| 6 |
And I do not want to provide the list each time |
| 7 |
But provide a text file that contains the list of features. |
| 8 |
|
| 9 |
. SPECIFICATION: behave file args |
| 10 |
. * Prepend an '@' char (AT) to the feature configfile name to classify it. |
| 11 |
. |
| 12 |
. SPECIFICATION: Feature listfile (text file) |
| 13 |
. * Each line contains a feature filename or directory with features |
| 14 |
. * Feature filenames/dirnames are relative to the feature configfile |
| 15 |
. * Empty lines are removed while reading |
| 16 |
. * Comment lines are removed while reading (start with '#' char) |
| 17 |
. * Wildcards are expanded to select 0..N files or directories. |
| 18 |
. * Wildcards for file locations are not supported (only filenames or dirs). |
| 19 |
. |
| 20 |
. SPECIFICATION: Runner |
| 21 |
. * Feature configfile with unknown/not found feature files |
| 22 |
. cause runner to fail. |
| 23 |
. |
| 24 |
. NOTE: Also supported by Cucumber. |
| 25 |
. RELATED: issue #75 |
| 26 |
|
| 27 |
|
| 28 |
@setup |
| 29 |
Scenario: Test Setup |
| 30 |
Given a new working directory |
| 31 |
And a file named "features/steps/steps.py" with: |
| 32 |
""" |
| 33 |
from behave import step |
| 34 |
|
| 35 |
@step('a step passes') |
| 36 |
def step_passes(context): |
| 37 |
pass |
| 38 |
""" |
| 39 |
And a file named "features/alice.feature" with: |
| 40 |
""" |
| 41 |
Feature: Alice |
| 42 |
Scenario: |
| 43 |
Given a step passes |
| 44 |
""" |
| 45 |
And a file named "features/bob.feature" with: |
| 46 |
""" |
| 47 |
Feature: Bob |
| 48 |
Scenario: |
| 49 |
Given a step passes |
| 50 |
""" |
| 51 |
|
| 52 |
|
| 53 |
Scenario: Use @feature_listfile in WORKDIR directory (above features/) |
| 54 |
Given a file named "alice_and_bob2.txt" with: |
| 55 |
""" |
| 56 |
features/alice.feature |
| 57 |
features/bob.feature |
| 58 |
""" |
| 59 |
When I run "behave @alice_and_bob2.txt" |
| 60 |
Then it should pass with: |
| 61 |
""" |
| 62 |
2 features passed, 0 failed, 0 skipped |
| 63 |
2 scenarios passed, 0 failed, 0 skipped |
| 64 |
2 steps passed, 0 failed, 0 skipped, 0 undefined |
| 65 |
""" |
| 66 |
|
| 67 |
|
| 68 |
Scenario: Use @feature_listfile in features/ subdirectory (Case 2) |
| 69 |
Given a file named "features/alice_and_bob.txt" with: |
| 70 |
""" |
| 71 |
alice.feature |
| 72 |
bob.feature |
| 73 |
""" |
| 74 |
When I run "behave @features/alice_and_bob.txt" |
| 75 |
Then it should pass with: |
| 76 |
""" |
| 77 |
2 features passed, 0 failed, 0 skipped |
| 78 |
2 scenarios passed, 0 failed, 0 skipped |
| 79 |
2 steps passed, 0 failed, 0 skipped, 0 undefined |
| 80 |
""" |
| 81 |
|
| 82 |
Scenario: Use @feature_listfile with some empty lines |
| 83 |
Given a file named "features/alice_and_bob_with_empty_lines.txt" with: |
| 84 |
""" |
| 85 |
alice.feature |
| 86 |
|
| 87 |
bob.feature |
| 88 |
""" |
| 89 |
When I run "behave @features/alice_and_bob_with_empty_lines.txt" |
| 90 |
Then it should pass with: |
| 91 |
""" |
| 92 |
2 features passed, 0 failed, 0 skipped |
| 93 |
2 scenarios passed, 0 failed, 0 skipped |
| 94 |
2 steps passed, 0 failed, 0 skipped, 0 undefined |
| 95 |
""" |
| 96 |
|
| 97 |
Scenario: Use @feature_listfile with some comment lines |
| 98 |
Given a file named "features/alice_and_bob_with_comment_lines.txt" with: |
| 99 |
""" |
| 100 |
alice.feature |
| 101 |
# -- USE: bob (comment line) |
| 102 |
bob.feature |
| 103 |
""" |
| 104 |
When I run "behave @features/alice_and_bob_with_comment_lines.txt" |
| 105 |
Then it should pass with: |
| 106 |
""" |
| 107 |
2 features passed, 0 failed, 0 skipped |
| 108 |
2 scenarios passed, 0 failed, 0 skipped |
| 109 |
2 steps passed, 0 failed, 0 skipped, 0 undefined |
| 110 |
""" |
| 111 |
|
| 112 |
Scenario: Use @feature_listfile with wildcards (Case 1) |
| 113 |
|
| 114 |
Use feature list-file with wildcard pattern to select features. |
| 115 |
|
| 116 |
Given a file named "with_wildcard_feature.txt" with: |
| 117 |
""" |
| 118 |
features/a*.feature |
| 119 |
""" |
| 120 |
When I run "behave -f plain --no-timings @with_wildcard_feature.txt" |
| 121 |
Then it should pass with: |
| 122 |
""" |
| 123 |
1 feature passed, 0 failed, 0 skipped |
| 124 |
1 scenario passed, 0 failed, 0 skipped |
| 125 |
""" |
| 126 |
And the command output should contain: |
| 127 |
""" |
| 128 |
Feature: Alice |
| 129 |
|
| 130 |
Scenario: |
| 131 |
Given a step passes ... passed |
| 132 |
""" |
| 133 |
|
| 134 |
Scenario: Use @feature_listfile with wildcards (Case 2) |
| 135 |
|
| 136 |
Use feature list-file with: |
| 137 |
- normal filename |
| 138 |
- wildcard pattern to select features |
| 139 |
|
| 140 |
Given a file named "with_wildcard_feature2.txt" with: |
| 141 |
""" |
| 142 |
features/alice.feature |
| 143 |
features/b*.feature |
| 144 |
""" |
| 145 |
When I run "behave -f plain --no-timings @with_wildcard_feature2.txt" |
| 146 |
Then it should pass with: |
| 147 |
""" |
| 148 |
2 features passed, 0 failed, 0 skipped |
| 149 |
2 scenarios passed, 0 failed, 0 skipped |
| 150 |
""" |
| 151 |
And the command output should contain: |
| 152 |
""" |
| 153 |
Feature: Alice |
| 154 |
|
| 155 |
Scenario: |
| 156 |
Given a step passes ... passed |
| 157 |
|
| 158 |
Feature: Bob |
| 159 |
|
| 160 |
Scenario: |
| 161 |
Given a step passes ... passed |
| 162 |
""" |
| 163 |
|
| 164 |
Scenario: Use @feature_listfile with wildcards for file location (not supported) |
| 165 |
|
| 166 |
Note that wildcards are not supported when file locations are used. |
| 167 |
|
| 168 |
Given a file named "with_wildcard_location.txt" with: |
| 169 |
""" |
| 170 |
features/a*.feature:3 |
| 171 |
""" |
| 172 |
When I run "behave -f plain --no-timings @with_wildcard_location.txt" |
| 173 |
Then it should fail with: |
| 174 |
""" |
| 175 |
ConfigError: No steps directory in '{__WORKDIR__}' |
| 176 |
""" |
| 177 |
|
| 178 |
|
| 179 |
Scenario: Use empty @feature_listfile (Case 1) |
| 180 |
Given an empty file named "empty.txt" |
| 181 |
When I run "behave @empty.txt" |
| 182 |
Then it should fail with: |
| 183 |
""" |
| 184 |
No steps directory in '{__WORKDIR__}' |
| 185 |
""" |
| 186 |
|
| 187 |
Scenario: Use empty @feature_listfile in features subdirectory (Case 2) |
| 188 |
Given an empty file named "features/empty.txt" |
| 189 |
When I run "behave @features/empty.txt" |
| 190 |
Then it should pass with: |
| 191 |
""" |
| 192 |
0 features passed, 0 failed, 0 skipped |
| 193 |
""" |
| 194 |
|
| 195 |
Scenario: Use @feature_listfile with unknown feature file (Case 1) |
| 196 |
Given a file named "with_unknown_feature.txt" with: |
| 197 |
""" |
| 198 |
features/alice.feature |
| 199 |
features/UNKNOWN.feature |
| 200 |
""" |
| 201 |
When I run "behave @with_unknown_feature.txt" |
| 202 |
Then it should fail with: |
| 203 |
""" |
| 204 |
Error: [Errno 2] No such file or directory: '{__WORKDIR__}/features/UNKNOWN.feature' |
| 205 |
""" |
| 206 |
|
| 207 |
Scenario: Use @feature_listfile with unknown feature file (Case 2) |
| 208 |
Given a file named "features/with_unknown_feature2.txt" with: |
| 209 |
""" |
| 210 |
UNKNOWN.feature |
| 211 |
""" |
| 212 |
When I run "behave @features/with_unknown_feature2.txt" |
| 213 |
Then it should fail with: |
| 214 |
""" |
| 215 |
Error: [Errno 2] No such file or directory: '{__WORKDIR__}/features/UNKNOWN.feature' |
| 216 |
""" |
| 217 |
|
| 218 |
Scenario: Use unknown @feature_listfile |
| 219 |
When I run "behave @unknown_feature_configfile.txt" |
| 220 |
Then it should fail with: |
| 221 |
""" |
| 222 |
FileNotFoundError: unknown_feature_configfile.txt |
| 223 |
""" |