fixed test case finished event determination

Этот коммит содержится в:
gedi 2016-09-07 08:06:03 +03:00
родитель 78cb180a3a
коммит fb26a4d567
2 изменённых файлов: 35 добавлений и 7 удалений

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

@ -414,3 +414,26 @@ func (f *basefmt) snippets() string {
} }
return buf.String() return buf.String()
} }
func (f *basefmt) isLastStep(s *gherkin.Step) bool {
ft := f.features[len(f.features)-1]
for _, def := range ft.ScenarioDefinitions {
if outline, ok := def.(*gherkin.ScenarioOutline); ok {
for n, step := range outline.Steps {
if step.Location.Line == s.Location.Line {
return n == len(outline.Steps)-1
}
}
}
if scenario, ok := def.(*gherkin.Scenario); ok {
for n, step := range scenario.Steps {
if step.Location.Line == s.Location.Line {
return n == len(scenario.Steps)-1
}
}
}
}
return false
}

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

@ -112,14 +112,22 @@ func (f *events) Summary() {
status = pending status = pending
} }
} }
snips := f.snippets()
if len(snips) > 0 {
snips = "You can implement step definitions for undefined steps with these snippets:\n" + snips
}
f.event(&struct { f.event(&struct {
Event string `json:"event"` Event string `json:"event"`
Status string `json:"status"` Status string `json:"status"`
Timestamp int64 `json:"timestamp"` Timestamp int64 `json:"timestamp"`
Snippets string `json:"snippets"`
}{ }{
"TestRunFinished", "TestRunFinished",
status.String(), status.String(),
time.Now().UnixNano() / nanoSec, time.Now().UnixNano() / nanoSec,
snips,
}) })
} }
@ -146,15 +154,12 @@ func (f *events) step(res *stepResult) {
var finished bool var finished bool
var line int var line int
switch t := f.owner.(type) { switch t := f.owner.(type) {
case *gherkin.ScenarioOutline: case *gherkin.TableRow:
if t.Steps[len(t.Steps)-1].Location.Line == res.step.Location.Line { line = t.Location.Line
finished = true finished = f.isLastStep(res.step)
last := t.Examples[len(t.Examples)-1]
line = last.TableBody[len(last.TableBody)-1].Location.Line
}
case *gherkin.Scenario: case *gherkin.Scenario:
line = t.Location.Line line = t.Location.Line
finished = t.Steps[len(t.Steps)-1].Location.Line == res.step.Location.Line finished = f.isLastStep(res.step)
} }
if finished { if finished {