| 1 |
Feature: Scenario Outline -- Improvements |
| 2 |
|
| 3 |
As a behave user / test writer |
| 4 |
I want that Scenario Outline (as paramtrized Scenario) is improved |
| 5 |
So that I know better which example/row combination is run. |
| 6 |
|
| 7 |
. REQUIREMENTS: |
| 8 |
. * Generated scenario name should better indicate row/example combination. |
| 9 |
. * Naming schema for generated scenario names should be configurable. |
| 10 |
. * File location of generated scenario should represent row/example. |
| 11 |
. * It should be possible select all scenarios of an examples group. |
| 12 |
. |
| 13 |
. IMPROVEMENTS: |
| 14 |
. * annotate Scenario Outline name (with row.id, examples.name, ...) |
| 15 |
. * use placeholders (from row/example) in Scenario Outline tags. |
| 16 |
. * use placeholders (from row/example) in Scenario Outline name. |
| 17 |
. * use placeholders (from row/example) in Examples (group) name. |
| 18 |
. * file location for generated scenario is unique (selectable in rerun) |
| 19 |
. |
| 20 |
. SPECIFICATION: Special placeholders |
| 21 |
. |
| 22 |
. | Placeholder | Description | |
| 23 |
. | name | Name of the Scenario Outline. | |
| 24 |
. | examples.name | Name of the examples group (or empty string). | |
| 25 |
. | examples.index | Index of examples group (range: 1..N). | |
| 26 |
. | row.index | Index of row in examples group (range: 1..R). | |
| 27 |
. | row.id | Same as: "{example.index}.{row.index}" | |
| 28 |
. |
| 29 |
. RELATED: |
| 30 |
. * scenario_outline.name_annotation.feature |
| 31 |
. * scenario_outline.parametrized.feature |
| 32 |
|
| 33 |
@setup |
| 34 |
Scenario: Test Setup |
| 35 |
Given a new working directory |
| 36 |
And a file named "behave.ini" with: |
| 37 |
""" |
| 38 |
[behave] |
| 39 |
scenario_outline_annotation_schema = {name} -- @{row.id} {examples.name} |
| 40 |
show_timings = false |
| 41 |
show_skipped = false |
| 42 |
""" |
| 43 |
And a file named "features/named_examples.feature" with: |
| 44 |
""" |
| 45 |
Feature: |
| 46 |
Scenario Outline: Named Examples |
| 47 |
Given a param <param1> |
| 48 |
|
| 49 |
Examples: Alice |
| 50 |
| param1 | |
| 51 |
| 10 | |
| 52 |
| 42 | |
| 53 |
|
| 54 |
Examples: Bob |
| 55 |
| param1 | |
| 56 |
| 43 | |
| 57 |
""" |
| 58 |
And a file named "features/unnamed_examples.feature" with: |
| 59 |
""" |
| 60 |
Feature: |
| 61 |
Scenario Outline: Unnamed Examples |
| 62 |
Given a param <param1> |
| 63 |
|
| 64 |
Examples: |
| 65 |
| param1 | |
| 66 |
| 100 | |
| 67 |
| 101 | |
| 68 |
""" |
| 69 |
And a file named "features/steps/param_steps.py" with: |
| 70 |
""" |
| 71 |
from behave import step |
| 72 |
|
| 73 |
@step('a param {value:w}') |
| 74 |
def step_impl_with_param(context, value): |
| 75 |
context.param = value |
| 76 |
|
| 77 |
@step('a param {name}={value}') |
| 78 |
def step_impl_with_param_value(context, name, value): |
| 79 |
context.param_name = name |
| 80 |
context.param_value = value |
| 81 |
""" |
| 82 |
|
| 83 |
Scenario: Unique File Locations in generated scenarios |
| 84 |
When I run "behave -f pretty -c features/named_examples.feature" |
| 85 |
Then it should pass with: |
| 86 |
""" |
| 87 |
Scenario Outline: Named Examples -- @1.1 Alice # features/named_examples.feature:7 |
| 88 |
Given a param 10 # features/steps/param_steps.py:3 |
| 89 |
|
| 90 |
Scenario Outline: Named Examples -- @1.2 Alice # features/named_examples.feature:8 |
| 91 |
Given a param 42 # features/steps/param_steps.py:3 |
| 92 |
|
| 93 |
Scenario Outline: Named Examples -- @2.1 Bob # features/named_examples.feature:12 |
| 94 |
Given a param 43 # features/steps/param_steps.py:3 |
| 95 |
""" |
| 96 |
But note that "each generated scenario has unique file location (related to row.line)" |
| 97 |
|
| 98 |
|
| 99 |
Scenario: Select generated scenario by unique File Location |
| 100 |
When I run "behave -f plain features/named_examples.feature:8" |
| 101 |
Then it should pass with: |
| 102 |
""" |
| 103 |
1 scenario passed, 0 failed, 2 skipped |
| 104 |
1 step passed, 0 failed, 2 skipped, 0 undefined |
| 105 |
""" |
| 106 |
And the command output should contain: |
| 107 |
""" |
| 108 |
Scenario Outline: Named Examples -- @1.2 Alice |
| 109 |
Given a param 42 ... passed |
| 110 |
""" |
| 111 |
|
| 112 |
@xfail |
| 113 |
Scenario: Select all generated scenarios of a Scenario Outline by File Location |
| 114 |
Given a file named "behave.ini" with: |
| 115 |
""" |
| 116 |
[behave] |
| 117 |
scenario_outline_annotation_schema = {name} -- @{row.id} {examples.name} |
| 118 |
""" |
| 119 |
When I run "behave -f plain features/named_examples.feature:2" |
| 120 |
Then it should pass with: |
| 121 |
""" |
| 122 |
3 scenarios passed, 0 failed, 0 skipped |
| 123 |
3 step passed, 0 failed, 0 skipped, 0 undefined |
| 124 |
""" |
| 125 |
And the command output should contain: |
| 126 |
""" |
| 127 |
Scenario Outline: Named Examples -- @1.2 Alice |
| 128 |
Given a param 42 ... passed |
| 129 |
""" |
| 130 |
|
| 131 |
@select.examples.by_name |
| 132 |
Scenario: Select Examples (Group) by Name (Case: name part) |
| 133 |
When I run "behave --name=Alice -f plain features/named_examples.feature" |
| 134 |
Then it should pass with: |
| 135 |
""" |
| 136 |
2 scenarios passed, 0 failed, 1 skipped |
| 137 |
2 steps passed, 0 failed, 1 skipped, 0 undefined |
| 138 |
""" |
| 139 |
And the command output should contain: |
| 140 |
""" |
| 141 |
Scenario Outline: Named Examples -- @1.1 Alice |
| 142 |
Given a param 10 ... passed |
| 143 |
|
| 144 |
Scenario Outline: Named Examples -- @1.2 Alice |
| 145 |
Given a param 42 ... passed |
| 146 |
""" |
| 147 |
|
| 148 |
@select.examples.by_name |
| 149 |
Scenario: Select Examples (Group) by Name (Case: regular expression) |
| 150 |
When I run "behave --name='-- @.* Alice' -f plain features/named_examples.feature" |
| 151 |
Then it should pass with: |
| 152 |
""" |
| 153 |
2 scenarios passed, 0 failed, 1 skipped |
| 154 |
2 steps passed, 0 failed, 1 skipped, 0 undefined |
| 155 |
""" |
| 156 |
And the command output should contain: |
| 157 |
""" |
| 158 |
Scenario Outline: Named Examples -- @1.1 Alice |
| 159 |
Given a param 10 ... passed |
| 160 |
|
| 161 |
Scenario Outline: Named Examples -- @1.2 Alice |
| 162 |
Given a param 42 ... passed |
| 163 |
""" |
| 164 |
|
| 165 |
@select.examples.by_name |
| 166 |
Scenario: Select one Example by Name |
| 167 |
When I run "behave --name='-- @1.2 Alice' -f plain features/named_examples.feature" |
| 168 |
Then it should pass with: |
| 169 |
""" |
| 170 |
1 scenario passed, 0 failed, 2 skipped |
| 171 |
1 step passed, 0 failed, 2 skipped, 0 undefined |
| 172 |
""" |
| 173 |
And the command output should contain: |
| 174 |
""" |
| 175 |
Scenario Outline: Named Examples -- @1.2 Alice |
| 176 |
Given a param 42 ... passed |
| 177 |
""" |