be compatible with gherkin library changes

the downside is that if outline examples are empty
it won't be pretty printed as node. But that does not make
much difference anyway
Этот коммит содержится в:
gedi 2016-03-04 12:59:56 +02:00
родитель 34899b4d05
коммит e9c3d69e2d
4 изменённых файлов: 29 добавлений и 4 удалений

4
fmt.go
Просмотреть файл

@ -221,7 +221,9 @@ func (f *basefmt) Summary() {
total++
case *gherkin.ScenarioOutline:
for _, ex := range t.Examples {
total += len(ex.TableBody)
if examples, hasExamples := examples(ex); hasExamples {
total += len(examples.TableBody)
}
}
}
}

Просмотреть файл

@ -122,7 +122,13 @@ func (f *pretty) printOutlineExample(outline *gherkin.ScenarioOutline) {
var msg string
clr := green
example := outline.Examples[f.outlineNumExample]
ex := outline.Examples[f.outlineNumExample]
example, hasExamples := examples(ex)
if !hasExamples {
// do not print empty examples
return
}
firstExample := f.outlineNumExamples == len(example.TableBody)
printSteps := firstExample && f.outlineNumExample == 0

10
gherkin.go Обычный файл
Просмотреть файл

@ -0,0 +1,10 @@
package godog
import "gopkg.in/cucumber/gherkin-go.v3"
// examples is a helper func to cast gherkin.Examples
// or gherkin.BaseExamples if its empty
func examples(ex interface{}) (*gherkin.Examples, bool) {
t, ok := ex.(*gherkin.Examples)
return t, ok
}

Просмотреть файл

@ -265,9 +265,16 @@ func (s *Suite) skipSteps(steps []*gherkin.Step) {
func (s *Suite) runOutline(outline *gherkin.ScenarioOutline, b *gherkin.Background) (failErr error) {
s.fmt.Node(outline)
for _, example := range outline.Examples {
s.fmt.Node(example)
for _, ex := range outline.Examples {
example, hasExamples := examples(ex)
if !hasExamples {
// @TODO: may need to print empty example node, but
// for backward compatibility, cannot cast to *gherkin.ExamplesBase
// at the moment
continue
}
s.fmt.Node(example)
placeholders := example.TableHeader.Cells
groups := example.TableBody