File tree Expand file tree Collapse file tree 4 files changed +29
-4
lines changed Expand file tree Collapse file tree 4 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -221,7 +221,9 @@ func (f *basefmt) Summary() {
221
221
total ++
222
222
case * gherkin.ScenarioOutline :
223
223
for _ , ex := range t .Examples {
224
- total += len (ex .TableBody )
224
+ if examples , hasExamples := examples (ex ); hasExamples {
225
+ total += len (examples .TableBody )
226
+ }
225
227
}
226
228
}
227
229
}
Original file line number Diff line number Diff line change @@ -122,7 +122,13 @@ func (f *pretty) printOutlineExample(outline *gherkin.ScenarioOutline) {
122
122
var msg string
123
123
clr := green
124
124
125
- example := outline .Examples [f .outlineNumExample ]
125
+ ex := outline .Examples [f .outlineNumExample ]
126
+ example , hasExamples := examples (ex )
127
+ if ! hasExamples {
128
+ // do not print empty examples
129
+ return
130
+ }
131
+
126
132
firstExample := f .outlineNumExamples == len (example .TableBody )
127
133
printSteps := firstExample && f .outlineNumExample == 0
128
134
Original file line number Diff line number Diff line change
1
+ package godog
2
+
3
+ import "gopkg.in/cucumber/gherkin-go.v3"
4
+
5
+ // examples is a helper func to cast gherkin.Examples
6
+ // or gherkin.BaseExamples if its empty
7
+ func examples (ex interface {}) (* gherkin.Examples , bool ) {
8
+ t , ok := ex .(* gherkin.Examples )
9
+ return t , ok
10
+ }
Original file line number Diff line number Diff line change @@ -265,9 +265,16 @@ func (s *Suite) skipSteps(steps []*gherkin.Step) {
265
265
func (s * Suite ) runOutline (outline * gherkin.ScenarioOutline , b * gherkin.Background ) (failErr error ) {
266
266
s .fmt .Node (outline )
267
267
268
- for _ , example := range outline .Examples {
269
- s .fmt .Node (example )
268
+ for _ , ex := range outline .Examples {
269
+ example , hasExamples := examples (ex )
270
+ if ! hasExamples {
271
+ // @TODO: may need to print empty example node, but
272
+ // for backward compatibility, cannot cast to *gherkin.ExamplesBase
273
+ // at the moment
274
+ continue
275
+ }
270
276
277
+ s .fmt .Node (example )
271
278
placeholders := example .TableHeader .Cells
272
279
groups := example .TableBody
273
280
You can’t perform that action at this time.
0 commit comments