@@ -38,9 +38,10 @@ type pretty struct {
38
38
outline * gherkin.ScenarioOutline
39
39
40
40
// state
41
- bgSteps int
42
- steps int
43
- commentPos int
41
+ bgSteps int
42
+ totalBgSteps int
43
+ steps int
44
+ commentPos int
44
45
45
46
// whether scenario or scenario outline keyword was printed
46
47
scenarioKeyword bool
@@ -68,8 +69,10 @@ func (f *pretty) Feature(ft *gherkin.Feature, p string, c []byte) {
68
69
f .scenario = nil
69
70
f .outline = nil
70
71
f .bgSteps = 0
72
+ f .totalBgSteps = 0
71
73
if ft .Background != nil {
72
74
f .bgSteps = len (ft .Background .Steps )
75
+ f .totalBgSteps = len (ft .Background .Steps )
73
76
}
74
77
}
75
78
@@ -84,15 +87,15 @@ func (f *pretty) Node(node interface{}) {
84
87
case * gherkin.Scenario :
85
88
f .scenario = t
86
89
f .outline = nil
87
- f .steps = len (t .Steps ) + f .bgSteps
90
+ f .steps = len (t .Steps ) + f .totalBgSteps
88
91
f .scenarioKeyword = false
89
92
case * gherkin.ScenarioOutline :
90
93
f .outline = t
91
94
f .scenario = nil
92
95
f .outlineNumExample = - 1
93
96
f .scenarioKeyword = false
94
97
case * gherkin.TableRow :
95
- f .steps = len (f .outline .Steps ) + f .bgSteps
98
+ f .steps = len (f .outline .Steps ) + f .totalBgSteps
96
99
f .outlineSteps = []* stepResult {}
97
100
}
98
101
}
@@ -157,10 +160,10 @@ func (f *pretty) printOutlineExample(outline *gherkin.ScenarioOutline) {
157
160
case res .typ == skipped && clr == nil :
158
161
clr = cyan
159
162
}
160
- if printSteps {
163
+ if printSteps && i >= f . totalBgSteps {
161
164
// in first example, we need to print steps
162
165
var text string
163
- ostep := outline .Steps [i ]
166
+ ostep := outline .Steps [i - f . totalBgSteps ]
164
167
if res .def != nil {
165
168
if m := outlinePlaceholderRegexp .FindAllStringIndex (ostep .Text , - 1 ); len (m ) > 0 {
166
169
var pos int
@@ -180,6 +183,23 @@ func (f *pretty) printOutlineExample(outline *gherkin.ScenarioOutline) {
180
183
}
181
184
// print the step outline
182
185
fmt .Fprintln (f .out , s (f .indent * 2 )+ cyan (strings .TrimSpace (ostep .Keyword ))+ " " + text )
186
+
187
+ // print step argument
188
+ // @TODO: need to make example header cells bold
189
+ switch t := ostep .Argument .(type ) {
190
+ case * gherkin.DataTable :
191
+ f .printTable (t , cyan )
192
+ case * gherkin.DocString :
193
+ var ct string
194
+ if len (t .ContentType ) > 0 {
195
+ ct = " " + cyan (t .ContentType )
196
+ }
197
+ fmt .Fprintln (f .out , s (f .indent * 3 )+ cyan (t .Delimitter )+ ct )
198
+ for _ , ln := range strings .Split (t .Content , "\n " ) {
199
+ fmt .Fprintln (f .out , s (f .indent * 3 )+ cyan (ln ))
200
+ }
201
+ fmt .Fprintln (f .out , s (f .indent * 3 )+ cyan (t .Delimitter ))
202
+ }
183
203
}
184
204
}
185
205
@@ -256,6 +276,11 @@ func (f *pretty) printStep(step *gherkin.Step, def *StepDef, c colors.ColorFunc)
256
276
}
257
277
258
278
func (f * pretty ) printStepKind (res * stepResult ) {
279
+ f .steps --
280
+ if f .outline != nil {
281
+ f .outlineSteps = append (f .outlineSteps , res )
282
+ }
283
+
259
284
// if has not printed background yet
260
285
switch {
261
286
// first background step
@@ -281,12 +306,8 @@ func (f *pretty) printStepKind(res *stepResult) {
281
306
fmt .Fprintln (f .out , "\n " + text )
282
307
f .scenarioKeyword = true
283
308
}
284
- f .steps --
285
309
// first step of outline scenario, print header and calculate comment position
286
310
case f .outline != nil :
287
- f .outlineSteps = append (f .outlineSteps , res )
288
- f .steps --
289
-
290
311
// print scenario keyword and value if first example
291
312
if ! f .scenarioKeyword {
292
313
f .commentPos = f .longestStep (f .outline .Steps , f .length (f .outline ))
@@ -300,7 +321,7 @@ func (f *pretty) printStepKind(res *stepResult) {
300
321
fmt .Fprintln (f .out , "\n " + text )
301
322
f .scenarioKeyword = true
302
323
}
303
- if len (f .outlineSteps ) == len (f .outline .Steps )+ f .bgSteps {
324
+ if len (f .outlineSteps ) == len (f .outline .Steps )+ f .totalBgSteps {
304
325
// an outline example steps has went through
305
326
f .printOutlineExample (f .outline )
306
327
f .outlineNumExamples --
0 commit comments