| 1 |
Feature: Multiple Formatter with different outputs |
| 2 |
|
| 3 |
. SPECIFICATION: Command-line option --format |
| 4 |
. * Each --format option specifies one formatter to use. |
| 5 |
. |
| 6 |
. SPECIFICATION: Command-line option --outfile |
| 7 |
. * Multiple --outfile options can be provided |
| 8 |
. * The nth --outfile option is used for the nth formatter |
| 9 |
. * If less --outfile options are provided than formatter, |
| 10 |
. the remaining formatter use stdout as output stream. |
| 11 |
. Therefore, the last formatter should in general use stdout. |
| 12 |
. |
| 13 |
. SPECIFICATION: Configuration file |
| 14 |
. * Option format with one or more formatters can be used (optional). |
| 15 |
. * Formatters specified in the configuration file are always executed. |
| 16 |
. * If not enough outfiles are specified, the outfiles list is extended |
| 17 |
. by using an outfile "${format}.output" for each missing outfile. |
| 18 |
. |
| 19 |
. RELATED TO: |
| 20 |
. * issue #47 Formatter chain is broken |
| 21 |
|
| 22 |
|
| 23 |
@setup |
| 24 |
Scenario: Test Setup |
| 25 |
Given a new working directory |
| 26 |
And a file named "features/steps/passing_steps.py" with: |
| 27 |
""" |
| 28 |
from behave import step |
| 29 |
|
| 30 |
@step('a step passes') |
| 31 |
def step_passes(context): |
| 32 |
pass |
| 33 |
""" |
| 34 |
And a file named "features/alice.feature" with: |
| 35 |
""" |
| 36 |
Feature: Alice |
| 37 |
Scenario: A1 |
| 38 |
Given a step passes |
| 39 |
When a step passes |
| 40 |
Then a step passes |
| 41 |
""" |
| 42 |
And a file named "features/bob.feature" with: |
| 43 |
""" |
| 44 |
Feature: Bob |
| 45 |
Scenario: B1 |
| 46 |
When a step passes |
| 47 |
Then a step passes |
| 48 |
""" |
| 49 |
|
| 50 |
@no_configfile |
| 51 |
Scenario: One formatter, no outfile (use stdout instead) |
| 52 |
Given a file named "behave.ini" does not exist |
| 53 |
When I run "behave -f plain -T features/" |
| 54 |
Then it should pass with: |
| 55 |
""" |
| 56 |
2 features passed, 0 failed, 0 skipped |
| 57 |
2 scenarios passed, 0 failed, 0 skipped |
| 58 |
""" |
| 59 |
And the command output should contain: |
| 60 |
""" |
| 61 |
Feature: Alice |
| 62 |
Scenario: A1 |
| 63 |
Given a step passes ... passed |
| 64 |
When a step passes ... passed |
| 65 |
Then a step passes ... passed |
| 66 |
|
| 67 |
Feature: Bob |
| 68 |
Scenario: B1 |
| 69 |
When a step passes ... passed |
| 70 |
Then a step passes ... passed |
| 71 |
""" |
| 72 |
|
| 73 |
@no_configfile |
| 74 |
Scenario: One formatter, one outfile |
| 75 |
Given a file named "behave.ini" does not exist |
| 76 |
When I run "behave -f plain --outfile=output/plain.out -T features/" |
| 77 |
Then it should pass with: |
| 78 |
""" |
| 79 |
2 features passed, 0 failed, 0 skipped |
| 80 |
2 scenarios passed, 0 failed, 0 skipped |
| 81 |
""" |
| 82 |
And the command output should not contain: |
| 83 |
""" |
| 84 |
Feature: Alice |
| 85 |
Scenario: A1 |
| 86 |
""" |
| 87 |
But a file named "output/plain.out" should exist |
| 88 |
And the file "output/plain.out" should contain: |
| 89 |
""" |
| 90 |
Feature: Alice |
| 91 |
Scenario: A1 |
| 92 |
Given a step passes ... passed |
| 93 |
When a step passes ... passed |
| 94 |
Then a step passes ... passed |
| 95 |
|
| 96 |
Feature: Bob |
| 97 |
Scenario: B1 |
| 98 |
When a step passes ... passed |
| 99 |
Then a step passes ... passed |
| 100 |
""" |
| 101 |
|
| 102 |
@no_configfile |
| 103 |
Scenario: Two formatter, one outfile |
| 104 |
Given a file named "behave.ini" does not exist |
| 105 |
When I run "behave -f plain -o output/plain.out -f progress -T features/" |
| 106 |
Then it should pass with: |
| 107 |
""" |
| 108 |
2 features passed, 0 failed, 0 skipped |
| 109 |
2 scenarios passed, 0 failed, 0 skipped |
| 110 |
""" |
| 111 |
And the command output should contain: |
| 112 |
""" |
| 113 |
features/alice.feature . |
| 114 |
features/bob.feature . |
| 115 |
""" |
| 116 |
But a file named "output/plain.out" should exist |
| 117 |
And the file "output/plain.out" should contain: |
| 118 |
""" |
| 119 |
Feature: Alice |
| 120 |
Scenario: A1 |
| 121 |
Given a step passes ... passed |
| 122 |
When a step passes ... passed |
| 123 |
Then a step passes ... passed |
| 124 |
|
| 125 |
Feature: Bob |
| 126 |
Scenario: B1 |
| 127 |
When a step passes ... passed |
| 128 |
Then a step passes ... passed |
| 129 |
""" |
| 130 |
|
| 131 |
|
| 132 |
@no_configfile |
| 133 |
Scenario: More outfiles than formatter should fail with CONFIG-ERROR |
| 134 |
Given a file named "behave.ini" does not exist |
| 135 |
When I run "behave -f plain -o plain.output -o xxx.output features/" |
| 136 |
Then it should fail with: |
| 137 |
""" |
| 138 |
CONFIG-ERROR: More outfiles (2) than formatters (1). |
| 139 |
""" |
| 140 |
|
| 141 |
@with_configfile |
| 142 |
Scenario: Use default formatter and outfile from behave configuration file |
| 143 |
Given a file named "behave.ini" with: |
| 144 |
""" |
| 145 |
[behave] |
| 146 |
format = plain |
| 147 |
outfiles = output/plain.out |
| 148 |
show_timings = false |
| 149 |
""" |
| 150 |
And I remove the directory "output" |
| 151 |
When I run "behave features/" |
| 152 |
Then it should pass |
| 153 |
And the command output should not contain: |
| 154 |
""" |
| 155 |
Feature: Alice |
| 156 |
Scenario: A1 |
| 157 |
""" |
| 158 |
But a file named "output/plain.out" should exist |
| 159 |
And the file "output/plain.out" should contain: |
| 160 |
""" |
| 161 |
Feature: Alice |
| 162 |
Scenario: A1 |
| 163 |
Given a step passes ... passed |
| 164 |
When a step passes ... passed |
| 165 |
Then a step passes ... passed |
| 166 |
|
| 167 |
Feature: Bob |
| 168 |
Scenario: B1 |
| 169 |
When a step passes ... passed |
| 170 |
Then a step passes ... passed |
| 171 |
""" |
| 172 |
|
| 173 |
@with_configfile |
| 174 |
Scenario: Use default formatter and another without outfile from behave configuration file |
| 175 |
Given a file named "behave.ini" with: |
| 176 |
""" |
| 177 |
[behave] |
| 178 |
default_format = plain |
| 179 |
format = progress |
| 180 |
# -- OOPS: No outfile specified => Use "${format}.output" as outfile |
| 181 |
show_timings = false |
| 182 |
""" |
| 183 |
And I remove the directory "output" |
| 184 |
When I run "behave features/" |
| 185 |
Then it should pass |
| 186 |
And the command output should contain: |
| 187 |
""" |
| 188 |
Feature: Alice |
| 189 |
Scenario: A1 |
| 190 |
Given a step passes ... passed |
| 191 |
When a step passes ... passed |
| 192 |
Then a step passes ... passed |
| 193 |
|
| 194 |
Feature: Bob |
| 195 |
Scenario: B1 |
| 196 |
When a step passes ... passed |
| 197 |
Then a step passes ... passed |
| 198 |
""" |
| 199 |
And a file named "progress.output" should exist |
| 200 |
And the file "progress.output" should contain: |
| 201 |
""" |
| 202 |
features/alice.feature . |
| 203 |
features/bob.feature . |
| 204 |
""" |
| 205 |
|
| 206 |
|
| 207 |
@with_configfile |
| 208 |
Scenario: Command-line formatter/outfile extend behave configuration file args |
| 209 |
Given a file named "behave.ini" with: |
| 210 |
""" |
| 211 |
[behave] |
| 212 |
show_timings = false |
| 213 |
format = plain |
| 214 |
outfiles = output/plain.out |
| 215 |
""" |
| 216 |
And I remove the directory "output" |
| 217 |
When I run "behave -c -f pretty -o output/pretty.out -f progress -o output/progress.out features/" |
| 218 |
Then it should pass |
| 219 |
And the file "output/progress.out" should contain: |
| 220 |
""" |
| 221 |
features/alice.feature . |
| 222 |
features/bob.feature . |
| 223 |
""" |
| 224 |
And the file "output/pretty.out" should contain: |
| 225 |
""" |
| 226 |
Feature: Alice # features/alice.feature:1 |
| 227 |
Scenario: A1 # features/alice.feature:2 |
| 228 |
Given a step passes # features/steps/passing_steps.py:3 |
| 229 |
When a step passes # features/steps/passing_steps.py:3 |
| 230 |
Then a step passes # features/steps/passing_steps.py:3 |
| 231 |
|
| 232 |
Feature: Bob # features/bob.feature:1 |
| 233 |
Scenario: B1 # features/bob.feature:2 |
| 234 |
When a step passes # features/steps/passing_steps.py:3 |
| 235 |
Then a step passes # features/steps/passing_steps.py:3 |
| 236 |
""" |
| 237 |
And a file named "output/plain.out" should exist |
| 238 |
And the file "output/plain.out" should contain: |
| 239 |
""" |
| 240 |
Feature: Alice |
| 241 |
Scenario: A1 |
| 242 |
Given a step passes ... passed |
| 243 |
When a step passes ... passed |
| 244 |
Then a step passes ... passed |
| 245 |
|
| 246 |
Feature: Bob |
| 247 |
Scenario: B1 |
| 248 |
When a step passes ... passed |
| 249 |
Then a step passes ... passed |
| 250 |
""" |
| 251 |
|
| 252 |
|
| 253 |
@with_configfile |
| 254 |
Scenario: Combination of formatter from configfile and command-line cannot cause outfile offsets |
| 255 |
Given a file named "behave.ini" with: |
| 256 |
""" |
| 257 |
[behave] |
| 258 |
show_timings = false |
| 259 |
format = plain |
| 260 |
# -- OOPS: No outfiles defined => Use "${format}.output" as outfile. |
| 261 |
""" |
| 262 |
And I remove the directory "output" |
| 263 |
When I run "behave -f progress -o output/progress.out features/" |
| 264 |
Then it should pass |
| 265 |
And the command output should not contain: |
| 266 |
""" |
| 267 |
Feature: Alice |
| 268 |
Scenario: A1 |
| 269 |
Given a step passes ... passed |
| 270 |
When a step passes ... passed |
| 271 |
Then a step passes ... passed |
| 272 |
""" |
| 273 |
But the file "plain.output" should contain: |
| 274 |
""" |
| 275 |
Feature: Alice |
| 276 |
Scenario: A1 |
| 277 |
Given a step passes ... passed |
| 278 |
When a step passes ... passed |
| 279 |
Then a step passes ... passed |
| 280 |
""" |
| 281 |
And the file "output/progress.out" should contain: |
| 282 |
""" |
| 283 |
features/alice.feature . |
| 284 |
features/bob.feature . |
| 285 |
""" |