File: runner.default_format.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 (175 lines) | stat: -rw-r--r-- 5,263 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
@sequential
Feature: Default Formatter

  . SPECIFICATION:
  .  * Default formatter is used when no other formatter is specified/provided.
  .  * Default formatter uses stdout as default output/outfile.
  .  * Pretty formatter is the default formatter.
  .  * Behave configfile can specify the default formatter.


    @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: Pretty formatter is used as default formatter if no other is defined
      Given a file named "behave.ini" does not exist
      When I run "behave -c 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 # 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
        """


    @with_configfile
    Scenario: Configfile can define own default formatter
      Given a file named "behave.ini" with:
        """
        [behave]
        default_format = plain
        show_timings = false
        """
      When I run "behave 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
        """

    @with_configfile
    Scenario: Use default formatter with own outfile instead of stdout
      Given a file named "behave.ini" with:
        """
        [behave]
        default_format = plain
        show_timings = false
        """
      When I run "behave --outfile=output/default.out features/"
      Then it should pass with:
        """
        2 features passed, 0 failed, 0 skipped
        2 scenarios passed, 0 failed, 0 skipped
        """
      And the file "output/default.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: Can override default formatter from configfile on command-line
      Given a file named "behave.ini" with:
        """
        [behave]
        default_format = plain
        show_timings = false
        """
      When I run "behave -f progress 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  .
        """


    # -- Some formatter are specified in configfile.
    @with_configfile
    Scenario: Default formatter is used when non is provided on command-line
      Given a file named "behave.ini" with:
        """
        [behave]
        default_format = plain
        format = progress
        outfiles = output/progress.out
        show_timings = false
        """
      And I remove the directory "output"
      When I run "behave 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
        """
      And the file "output/progress.out" should contain:
        """
        features/alice.feature  .
        features/bob.feature  .
        """