fix snippet trailing space, missing event for test case finish
Этот коммит содержится в:
родитель
fb26a4d567
коммит
8d911a71f0
2 изменённых файлов: 39 добавлений и 15 удалений
5
fmt.go
5
fmt.go
|
@ -31,8 +31,9 @@ var undefinedSnippetsTpl = template.Must(template.New("snippets").Funcs(snippetH
|
||||||
return godog.ErrPending
|
return godog.ErrPending
|
||||||
}
|
}
|
||||||
|
|
||||||
{{end}}func FeatureContext(s *godog.Suite) { {{ range . }}
|
{{end}}func FeatureContext(s *godog.Suite) { {{- range . }}
|
||||||
s.Step({{ backticked .Expr }}, {{ .Method }}){{end}}
|
s.Step({{ backticked .Expr }}, {{ .Method }})
|
||||||
|
{{- end}}
|
||||||
}
|
}
|
||||||
`))
|
`))
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ type events struct {
|
||||||
// threaded execution. Unless running a copy of formatter for each feature
|
// threaded execution. Unless running a copy of formatter for each feature
|
||||||
path string
|
path string
|
||||||
stat stepType // last step status, before skipped
|
stat stepType // last step status, before skipped
|
||||||
|
outlineSteps int // number of current outline scenario steps
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *events) event(ev interface{}) {
|
func (f *events) event(ev interface{}) {
|
||||||
|
@ -62,26 +63,46 @@ func (f *events) event(ev interface{}) {
|
||||||
func (f *events) Node(n interface{}) {
|
func (f *events) Node(n interface{}) {
|
||||||
f.basefmt.Node(n)
|
f.basefmt.Node(n)
|
||||||
|
|
||||||
|
var id string
|
||||||
|
var undefined bool
|
||||||
switch t := n.(type) {
|
switch t := n.(type) {
|
||||||
case *gherkin.Scenario:
|
case *gherkin.Scenario:
|
||||||
|
id = fmt.Sprintf("%s:%d", f.path, t.Location.Line)
|
||||||
|
undefined = len(t.Steps) == 0
|
||||||
|
case *gherkin.TableRow:
|
||||||
|
id = fmt.Sprintf("%s:%d", f.path, t.Location.Line)
|
||||||
|
undefined = f.outlineSteps == 0
|
||||||
|
case *gherkin.ScenarioOutline:
|
||||||
|
f.outlineSteps = len(t.Steps)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(id) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
f.event(&struct {
|
f.event(&struct {
|
||||||
Event string `json:"event"`
|
Event string `json:"event"`
|
||||||
Location string `json:"location"`
|
Location string `json:"location"`
|
||||||
Timestamp int64 `json:"timestamp"`
|
Timestamp int64 `json:"timestamp"`
|
||||||
}{
|
}{
|
||||||
"TestCaseStarted",
|
"TestCaseStarted",
|
||||||
fmt.Sprintf("%s:%d", f.path, t.Location.Line),
|
id,
|
||||||
time.Now().UnixNano() / nanoSec,
|
time.Now().UnixNano() / nanoSec,
|
||||||
})
|
})
|
||||||
case *gherkin.TableRow:
|
|
||||||
|
if undefined {
|
||||||
|
// @TODO: is status undefined or passed? when there are no steps
|
||||||
|
// for this scenario
|
||||||
f.event(&struct {
|
f.event(&struct {
|
||||||
Event string `json:"event"`
|
Event string `json:"event"`
|
||||||
Location string `json:"location"`
|
Location string `json:"location"`
|
||||||
Timestamp int64 `json:"timestamp"`
|
Timestamp int64 `json:"timestamp"`
|
||||||
|
Status string `json:"status"`
|
||||||
}{
|
}{
|
||||||
"TestCaseStarted",
|
"TestCaseFinished",
|
||||||
fmt.Sprintf("%s:%d", f.path, t.Location.Line),
|
id,
|
||||||
time.Now().UnixNano() / nanoSec,
|
time.Now().UnixNano() / nanoSec,
|
||||||
|
"undefined",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,11 +144,13 @@ func (f *events) Summary() {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Timestamp int64 `json:"timestamp"`
|
Timestamp int64 `json:"timestamp"`
|
||||||
Snippets string `json:"snippets"`
|
Snippets string `json:"snippets"`
|
||||||
|
Memory string `json:"memory"`
|
||||||
}{
|
}{
|
||||||
"TestRunFinished",
|
"TestRunFinished",
|
||||||
status.String(),
|
status.String(),
|
||||||
time.Now().UnixNano() / nanoSec,
|
time.Now().UnixNano() / nanoSec,
|
||||||
snips,
|
snips,
|
||||||
|
"", // @TODO not sure that could be correctly implemented
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче