| 1 |
@sequential |
| 2 |
Feature: Select feature files by using regular expressions |
| 3 |
|
| 4 |
As a tester |
| 5 |
I want to include/exclude feature files into/from a test run by using wildcards |
| 6 |
To be more flexible and avoid to specify all feature files |
| 7 |
|
| 8 |
. SPECIFICATION: |
| 9 |
. * behave provides --include and --exclude command line options |
| 10 |
. * --include option selects a subset of all files that should be included |
| 11 |
. * --exclude option is applied after include option is applied |
| 12 |
. |
| 13 |
. EXAMPLE: |
| 14 |
. behave --include="features/ali.*\.feature" ... |
| 15 |
. behave --exclude="features/ali.*" ... |
| 16 |
|
| 17 |
|
| 18 |
Background: |
| 19 |
Given behave has the following feature fileset: |
| 20 |
""" |
| 21 |
features/alice.feature |
| 22 |
features/bob.feature |
| 23 |
features/barbi.feature |
| 24 |
""" |
| 25 |
|
| 26 |
Scenario: Include only feature files |
| 27 |
When behave includes feature files with "features/a.*" |
| 28 |
And behave excludes no feature files |
| 29 |
Then the following feature files are selected: |
| 30 |
""" |
| 31 |
features/alice.feature |
| 32 |
""" |
| 33 |
|
| 34 |
Scenario: Include more than one feature file |
| 35 |
When behave includes feature files with "features/b.*" |
| 36 |
Then the following feature files are selected: |
| 37 |
""" |
| 38 |
features/bob.feature |
| 39 |
features/barbi.feature |
| 40 |
""" |
| 41 |
|
| 42 |
|
| 43 |
Scenario: Exclude only feature files |
| 44 |
When behave excludes feature files with "features/a.*" |
| 45 |
And behave includes all feature files |
| 46 |
Then the following feature files are selected: |
| 47 |
""" |
| 48 |
features/bob.feature |
| 49 |
features/barbi.feature |
| 50 |
""" |
| 51 |
|
| 52 |
Scenario: Exclude more than one feature file |
| 53 |
When behave excludes feature files with "features/b.*" |
| 54 |
Then the following feature files are selected: |
| 55 |
""" |
| 56 |
features/alice.feature |
| 57 |
""" |
| 58 |
|
| 59 |
Scenario: Include and exclude feature files |
| 60 |
|
| 61 |
Ensure that exclude file pattern is applied after include file pattern. |
| 62 |
|
| 63 |
When behave includes feature files with "features/.*a.*\.feature" |
| 64 |
And behave excludes feature files with ".*/barbi.*" |
| 65 |
Then the following feature files are selected: |
| 66 |
""" |
| 67 |
features/alice.feature |
| 68 |
""" |
| 69 |
|
| 70 |
Scenario: Include and exclude feature files (in 2 steps) |
| 71 |
|
| 72 |
Show how file inclusion/exclusion works by emulating the two steps. |
| 73 |
|
| 74 |
When behave includes feature files with "features/.*a.*\.feature" |
| 75 |
Then the following feature files are selected: |
| 76 |
""" |
| 77 |
features/alice.feature |
| 78 |
features/barbi.feature |
| 79 |
""" |
| 80 |
When behave excludes feature files with ".*/barbi.*" |
| 81 |
Then the following feature files are selected: |
| 82 |
""" |
| 83 |
features/alice.feature |
| 84 |
""" |