Debian Codegraph @

features/scenario_outline.name_annotation.feature

raw
1 Feature: Scenario Outline -- Scenario Name Annotations
2
3 As a behave user / test writer
4 I want to know in the current example/row combination
5 So that I know the context of success/failure within a test run (without details).
6
7 . REQUIREMENTS:
8 . * generated scenario name should better indicate row/example combination.
9 . * name annotation schema for generated scenario names should be configurable.
10 .
11 . IMPROVEMENTS:
12 . * annotate Scenario Outline name (with row.id, examples.name, ...)
13 .
14 .
15 . SCENARIO OUTLINE NAME ANNOTATION SCHEMA:
16 .
17 . scenario_outline_annotation_schema = "{name} -- @{row.id} {examples.name}"
18 .
19 . | Placeholder | Description |
20 . | name | Name of the Scenario Outline. |
21 . | examples.name | Name of the examples group (or empty string). |
22 . | examples.index | Index of examples group (range: 1..N). |
23 . | row.index | Index of row in examples group (range: 1..R). |
24 . | row.id | Same as: "{example.index}.{row.index}" |
25
26
27 @setup
28 Scenario: Test Setup
29 Given a new working directory
30 And a file named "features/named_examples.feature" with:
31 """
32 Feature:
33 Scenario Outline: Named Examples
34 Given a param <param1>
35
36 Examples: Alice
37 | param1 |
38 | 10 |
39 | 42 |
40
41 Examples: Bob
42 | param1 |
43 | 43 |
44 """
45 And a file named "features/unnamed_examples.feature" with:
46 """
47 Feature:
48 Scenario Outline: Unnamed Examples
49 Given a param <param1>
50
51 Examples:
52 | param1 |
53 | 100 |
54 | 101 |
55 """
56 And a file named "features/steps/param_steps.py" with:
57 """
58 from behave import step
59
60 @step('a param {value:w}')
61 def step_impl_with_param(context, value):
62 context.param = value
63
64 @step('a param {name}={value}')
65 def step_impl_with_param_value(context, name, value):
66 context.param_name = name
67 context.param_value = value
68
69 """
70
71 Scenario: Use default annotation schema for generated scenarios (name annotations)
72
73 Each example/row combination should be easy to spot.
74
75 Given a file named "behave.ini" does not exist
76 When I run "behave -f plain --no-timings features/named_examples.feature"
77 Then it should pass with:
78 """
79 Scenario Outline: Named Examples -- @1.1 Alice
80 Given a param 10 ... passed
81
82 Scenario Outline: Named Examples -- @1.2 Alice
83 Given a param 42 ... passed
84
85 Scenario Outline: Named Examples -- @2.1 Bob
86 Given a param 43 ... passed
87 """
88 And note that "the default annotation schema is: {name} -- @{row.id} {examples.name}"
89 When I run "behave -f plain --no-timings features/unnamed_examples.feature"
90 Then it should pass with:
91 """
92 Scenario Outline: Unnamed Examples -- @1.1
93 Given a param 100 ... passed
94
95 Scenario Outline: Unnamed Examples -- @1.2
96 Given a param 101 ... passed
97 """
98 But note that "each generated scenario name has a unique <row.id> annotation"
99 And note that "each generated scenario name contains has its <examples.name> as annotation"
100
101
102 Scenario: Use own annotation schema for generated scenarios (name annotations)
103 Given a file named "behave.ini" with:
104 """
105 [behave]
106 scenario_outline_annotation_schema = {name} -*- {examples.name} @{row.id}
107 """
108 When I run "behave -f plain --no-timings features/named_examples.feature"
109 Then it should pass with:
110 """
111 Scenario Outline: Named Examples -*- Alice @1.1
112 Given a param 10 ... passed
113
114 Scenario Outline: Named Examples -*- Alice @1.2
115 Given a param 42 ... passed
116
117 Scenario Outline: Named Examples -*- Bob @2.1
118 Given a param 43 ... passed
119 """
120 When I run "behave -f plain --no-timings features/unnamed_examples.feature"
121 Then it should pass with:
122 """
123 Scenario Outline: Unnamed Examples -*- @1.1
124 Given a param 100 ... passed
125
126 Scenario Outline: Unnamed Examples -*- @1.2
127 Given a param 101 ... passed
128 """
129
130
131 Scenario: Disable name annotations (use: old naming scheme)
132 Given a file named "behave.ini" with:
133 """
134 [behave]
135 scenario_outline_annotation_schema = {name}
136 """
137 When I run "behave -f plain --no-timings features/named_examples.feature"
138 Then it should pass with:
139 """
140 Scenario Outline: Named Examples
141 Given a param 10 ... passed
142
143 Scenario Outline: Named Examples
144 Given a param 42 ... passed
145
146 Scenario Outline: Named Examples
147 Given a param 43 ... passed
148 """
149 When I run "behave -f plain --no-timings features/unnamed_examples.feature"
150 Then it should pass with:
151 """
152 Scenario Outline: Unnamed Examples
153 Given a param 100 ... passed
154
155 Scenario Outline: Unnamed Examples
156 Given a param 101 ... passed
157 """