File: runner.multiple_formatters.feature

package info (click to toggle)
behave 1.2.6-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,160 kB
  • sloc: python: 19,857; makefile: 137; sh: 18
file content (285 lines) | stat: -rw-r--r-- 9,196 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
Feature: Multiple Formatter with different outputs

  . SPECIFICATION: Command-line option --format
  .  * Each --format option specifies one formatter to use.
  .
  . SPECIFICATION: Command-line option --outfile
  .  * Multiple --outfile options can be provided
  .  * The nth --outfile option is used for the nth formatter
  .  * If less --outfile options are provided than formatter,
  .    the remaining formatter use stdout as output stream.
  .    Therefore, the last formatter should in general use stdout.
  .
  . SPECIFICATION: Configuration file
  .  * Option format with one or more formatters can be used (optional).
  .  * Formatters specified in the configuration file are always executed.
  .  * If not enough outfiles are specified, the outfiles list is extended
  .    by using an outfile "${format}.output" for each missing outfile.
  .
  . RELATED TO:
  .  * issue #47  Formatter chain is broken


    @setup
    Scenario: Test Setup
      Given a new working directory
      And a file named "features/steps/passing_steps.py" with:
        """
        from behave import step

        @step('a step passes')
        def step_passes(context):
            pass
        """
      And a file named "features/alice.feature" with:
        """
        Feature: Alice
          Scenario: A1
            Given a step passes
            When a step passes
            Then a step passes
        """
      And a file named "features/bob.feature" with:
        """
        Feature: Bob
          Scenario: B1
            When a step passes
            Then a step passes
        """

    @no_configfile
    Scenario: One formatter, no outfile (use stdout instead)
      Given a file named "behave.ini" does not exist
      When I run "behave -f plain -T features/"
      Then it should pass with:
        """
        2 features passed, 0 failed, 0 skipped
        2 scenarios passed, 0 failed, 0 skipped
        """
      And the command output should contain:
        """
        Feature: Alice
          Scenario: A1
            Given a step passes ... passed
            When a step passes ... passed
            Then a step passes ... passed

        Feature: Bob
          Scenario: B1
            When a step passes ... passed
            Then a step passes ... passed
        """

    @no_configfile
    Scenario: One formatter, one outfile
      Given a file named "behave.ini" does not exist
      When I run "behave -f plain --outfile=output/plain.out -T features/"
      Then it should pass with:
        """
        2 features passed, 0 failed, 0 skipped
        2 scenarios passed, 0 failed, 0 skipped
        """
      And the command output should not contain:
        """
        Feature: Alice
          Scenario: A1
        """
      But a file named "output/plain.out" should exist
      And the file "output/plain.out" should contain:
        """
        Feature: Alice
          Scenario: A1
            Given a step passes ... passed
            When a step passes ... passed
            Then a step passes ... passed

        Feature: Bob
          Scenario: B1
            When a step passes ... passed
            Then a step passes ... passed
        """

    @no_configfile
    Scenario: Two formatter, one outfile
      Given a file named "behave.ini" does not exist
      When I run "behave -f plain -o output/plain.out -f progress -T features/"
      Then it should pass with:
        """
        2 features passed, 0 failed, 0 skipped
        2 scenarios passed, 0 failed, 0 skipped
        """
      And the command output should contain:
        """
        features/alice.feature  .
        features/bob.feature  .
        """
      But a file named "output/plain.out" should exist
      And the file "output/plain.out" should contain:
        """
        Feature: Alice
          Scenario: A1
            Given a step passes ... passed
            When a step passes ... passed
            Then a step passes ... passed

        Feature: Bob
          Scenario: B1
            When a step passes ... passed
            Then a step passes ... passed
        """


    @no_configfile
    Scenario: More outfiles than formatter should fail with CONFIG-ERROR
      Given a file named "behave.ini" does not exist
      When I run "behave -f plain -o plain.output -o xxx.output features/"
      Then it should fail with:
        """
        CONFIG-ERROR: More outfiles (2) than formatters (1).
        """

    @with_configfile
    Scenario: Use default formatter and outfile from behave configuration file
      Given a file named "behave.ini" with:
        """
        [behave]
        format   = plain
        outfiles = output/plain.out
        show_timings = false
        """
      And I remove the directory "output"
      When I run "behave features/"
      Then it should pass
      And the command output should not contain:
        """
        Feature: Alice
          Scenario: A1
        """
      But a file named "output/plain.out" should exist
      And the file "output/plain.out" should contain:
        """
        Feature: Alice
          Scenario: A1
            Given a step passes ... passed
            When a step passes ... passed
            Then a step passes ... passed

        Feature: Bob
          Scenario: B1
            When a step passes ... passed
            Then a step passes ... passed
        """

    @with_configfile
    Scenario: Use default formatter and another without outfile from behave configuration file
      Given a file named "behave.ini" with:
        """
        [behave]
        default_format = plain
        format = progress
        # -- OOPS: No outfile specified => Use "${format}.output" as outfile
        show_timings = false
        """
      And I remove the directory "output"
      When I run "behave features/"
      Then it should pass
      And the command output should contain:
        """
        Feature: Alice
          Scenario: A1
            Given a step passes ... passed
            When a step passes ... passed
            Then a step passes ... passed

        Feature: Bob
          Scenario: B1
            When a step passes ... passed
            Then a step passes ... passed
        """
      And a file named "progress.output" should exist
      And the file "progress.output" should contain:
        """
        features/alice.feature  .
        features/bob.feature  .
        """


    @with_configfile
    Scenario: Command-line formatter/outfile extend behave configuration file args
      Given a file named "behave.ini" with:
        """
        [behave]
        show_timings = false
        format   = plain
        outfiles = output/plain.out
        """
      And I remove the directory "output"
      When I run "behave -c -f pretty -o output/pretty.out -f progress -o output/progress.out features/"
      Then it should pass
      And the file "output/progress.out" should contain:
        """
        features/alice.feature  .
        features/bob.feature  .
        """
      And the file "output/pretty.out" should contain:
        """
        Feature: Alice # features/alice.feature:1
          Scenario: A1          # features/alice.feature:2
            Given a step passes # features/steps/passing_steps.py:3
            When a step passes  # features/steps/passing_steps.py:3
            Then a step passes  # features/steps/passing_steps.py:3

        Feature: Bob # features/bob.feature:1
          Scenario: B1         # features/bob.feature:2
            When a step passes # features/steps/passing_steps.py:3
            Then a step passes # features/steps/passing_steps.py:3
        """
      And a file named "output/plain.out" should exist
      And the file "output/plain.out" should contain:
        """
        Feature: Alice
          Scenario: A1
            Given a step passes ... passed
            When a step passes ... passed
            Then a step passes ... passed

        Feature: Bob
          Scenario: B1
            When a step passes ... passed
            Then a step passes ... passed
        """


    @with_configfile
    Scenario: Combination of formatter from configfile and command-line cannot cause outfile offsets
      Given a file named "behave.ini" with:
        """
        [behave]
        show_timings = false
        format = plain
        # -- OOPS: No outfiles defined => Use "${format}.output" as outfile.
        """
      And I remove the directory "output"
      When I run "behave -f progress -o output/progress.out features/"
      Then it should pass
      And the command output should not contain:
        """
        Feature: Alice
          Scenario: A1
            Given a step passes ... passed
            When a step passes ... passed
            Then a step passes ... passed
        """
      But the file "plain.output" should contain:
        """
        Feature: Alice
          Scenario: A1
            Given a step passes ... passed
            When a step passes ... passed
            Then a step passes ... passed
        """
      And the file "output/progress.out" should contain:
        """
        features/alice.feature  .
        features/bob.feature  .
        """