Debian Codegraph @

features/runner.default_format.feature

raw
1 @sequential
2 Feature: Default Formatter
3
4 . SPECIFICATION:
5 . * Default formatter is used when no other formatter is specified/provided.
6 . * Default formatter uses stdout as default output/outfile.
7 . * Pretty formatter is the default formatter.
8 . * Behave configfile can specify the default formatter.
9
10
11 @setup
12 Scenario: Test Setup
13 Given a new working directory
14 And a file named "features/steps/passing_steps.py" with:
15 """
16 from behave import step
17
18 @step('a step passes')
19 def step_passes(context):
20 pass
21 """
22 And a file named "features/alice.feature" with:
23 """
24 Feature: Alice
25 Scenario: A1
26 Given a step passes
27 When a step passes
28 Then a step passes
29 """
30 And a file named "features/bob.feature" with:
31 """
32 Feature: Bob
33 Scenario: B1
34 When a step passes
35 Then a step passes
36 """
37
38 @no_configfile
39 Scenario: Pretty formatter is used as default formatter if no other is defined
40 Given a file named "behave.ini" does not exist
41 When I run "behave -c features/"
42 Then it should pass with:
43 """
44 2 features passed, 0 failed, 0 skipped
45 2 scenarios passed, 0 failed, 0 skipped
46 """
47 And the command output should contain:
48 """
49 Feature: Alice # features/alice.feature:1
50 Scenario: A1 # features/alice.feature:2
51 Given a step passes # features/steps/passing_steps.py:3
52 When a step passes # features/steps/passing_steps.py:3
53 Then a step passes # features/steps/passing_steps.py:3
54
55 Feature: Bob # features/bob.feature:1
56 Scenario: B1 # features/bob.feature:2
57 When a step passes # features/steps/passing_steps.py:3
58 Then a step passes # features/steps/passing_steps.py:3
59 """
60
61
62 @with_configfile
63 Scenario: Configfile can define own default formatter
64 Given a file named "behave.ini" with:
65 """
66 [behave]
67 default_format = plain
68 show_timings = false
69 """
70 When I run "behave features/"
71 Then it should pass with:
72 """
73 2 features passed, 0 failed, 0 skipped
74 2 scenarios passed, 0 failed, 0 skipped
75 """
76 And the command output should contain:
77 """
78 Feature: Alice
79 Scenario: A1
80 Given a step passes ... passed
81 When a step passes ... passed
82 Then a step passes ... passed
83
84 Feature: Bob
85 Scenario: B1
86 When a step passes ... passed
87 Then a step passes ... passed
88 """
89
90 @with_configfile
91 Scenario: Use default formatter with own outfile instead of stdout
92 Given a file named "behave.ini" with:
93 """
94 [behave]
95 default_format = plain
96 show_timings = false
97 """
98 When I run "behave --outfile=output/default.out features/"
99 Then it should pass with:
100 """
101 2 features passed, 0 failed, 0 skipped
102 2 scenarios passed, 0 failed, 0 skipped
103 """
104 And the file "output/default.out" should contain:
105 """
106 Feature: Alice
107 Scenario: A1
108 Given a step passes ... passed
109 When a step passes ... passed
110 Then a step passes ... passed
111
112 Feature: Bob
113 Scenario: B1
114 When a step passes ... passed
115 Then a step passes ... passed
116 """
117
118
119 @with_configfile
120 Scenario: Can override default formatter from configfile on command-line
121 Given a file named "behave.ini" with:
122 """
123 [behave]
124 default_format = plain
125 show_timings = false
126 """
127 When I run "behave -f progress features/"
128 Then it should pass with:
129 """
130 2 features passed, 0 failed, 0 skipped
131 2 scenarios passed, 0 failed, 0 skipped
132 """
133 And the command output should contain:
134 """
135 features/alice.feature .
136 features/bob.feature .
137 """
138
139
140 # -- Some formatter are specified in configfile.
141 @with_configfile
142 Scenario: Default formatter is used when non is provided on command-line
143 Given a file named "behave.ini" with:
144 """
145 [behave]
146 default_format = plain
147 format = progress
148 outfiles = output/progress.out
149 show_timings = false
150 """
151 And I remove the directory "output"
152 When I run "behave features/"
153 Then it should pass with:
154 """
155 2 features passed, 0 failed, 0 skipped
156 2 scenarios passed, 0 failed, 0 skipped
157 """
158 And the command output should contain:
159 """
160 Feature: Alice
161 Scenario: A1
162 Given a step passes ... passed
163 When a step passes ... passed
164 Then a step passes ... passed
165
166 Feature: Bob
167 Scenario: B1
168 When a step passes ... passed
169 Then a step passes ... passed
170 """
171 And the file "output/progress.out" should contain:
172 """
173 features/alice.feature .
174 features/bob.feature .
175 """