Made progress formatter verification a bit more accurate
Этот коммит содержится в:
родитель
11dde19cd3
коммит
5d351e86c4
3 изменённых файлов: 28 добавлений и 46 удалений
|
@ -47,8 +47,7 @@ func TestProgressFormatterOutput(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
expected := `
|
||||
...F-.P-.UU.....F..P..U 23
|
||||
expected := `...F-.P-.UU.....F..P..U 23
|
||||
|
||||
|
||||
--- Failed steps:
|
||||
|
@ -79,13 +78,13 @@ func nextUndefined() error {
|
|||
func FeatureContext(s *godog.Suite) {
|
||||
s.Step(` + "`^undefined$`" + `, undefined)
|
||||
s.Step(` + "`^next undefined$`" + `, nextUndefined)
|
||||
}`
|
||||
}
|
||||
|
||||
`
|
||||
|
||||
require.True(t, r.run())
|
||||
|
||||
expected = trimAllLines(expected)
|
||||
actual := trimAllLines(buf.String())
|
||||
|
||||
actual := buf.String()
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
|
@ -111,7 +110,7 @@ func TestProgressFormatterWhenStepPanics(t *testing.T) {
|
|||
require.True(t, r.run())
|
||||
|
||||
actual := buf.String()
|
||||
assert.Contains(t, actual, "godog/fmt_progress_test.go:107")
|
||||
assert.Contains(t, actual, "godog/fmt_progress_test.go:106")
|
||||
}
|
||||
|
||||
func TestProgressFormatterWithPassingMultisteps(t *testing.T) {
|
||||
|
@ -163,8 +162,7 @@ func TestProgressFormatterWithFailingMultisteps(t *testing.T) {
|
|||
|
||||
require.True(t, r.run())
|
||||
|
||||
expected := `
|
||||
.F 2
|
||||
expected := `.F 2
|
||||
|
||||
|
||||
--- Failed steps:
|
||||
|
@ -179,8 +177,7 @@ Error: sub2: sub-sub: errored
|
|||
0s
|
||||
`
|
||||
|
||||
expected = trimAllLines(expected)
|
||||
actual := trimAllLines(buf.String())
|
||||
actual := buf.String()
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
|
@ -231,8 +228,7 @@ func TestProgressFormatterMultistepTemplates(t *testing.T) {
|
|||
|
||||
require.False(t, r.run())
|
||||
|
||||
expected := `
|
||||
.U 2
|
||||
expected := `.U 2
|
||||
|
||||
|
||||
1 scenarios (1 undefined)
|
||||
|
@ -258,11 +254,10 @@ func FeatureContext(s *godog.Suite) {
|
|||
s.Step(` + "`^unavailable \"([^\"]*)\" cost (\\d+)$`" + `, unavailableCost)
|
||||
s.Step(` + "`^three$`" + `, three)
|
||||
}
|
||||
|
||||
`
|
||||
|
||||
expected = trimAllLines(expected)
|
||||
actual := trimAllLines(buf.String())
|
||||
|
||||
actual := buf.String()
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
|
@ -333,8 +328,7 @@ Feature: basic
|
|||
|
||||
require.True(t, r.run())
|
||||
|
||||
expected := `
|
||||
.F 2
|
||||
expected := `.F 2
|
||||
|
||||
|
||||
--- Failed steps:
|
||||
|
@ -349,8 +343,6 @@ Feature: basic
|
|||
0s
|
||||
`
|
||||
|
||||
expected = trimAllLines(expected)
|
||||
actual := trimAllLines(buf.String())
|
||||
|
||||
actual := buf.String()
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
|
|
@ -3,17 +3,10 @@ package godog
|
|||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func trimLineSpaces(s string) string {
|
||||
var res []string
|
||||
for _, ln := range strings.Split(s, "\n") {
|
||||
res = append(res, strings.TrimSpace(ln))
|
||||
}
|
||||
return strings.Join(res, "\n")
|
||||
}
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func callstack1() *stack {
|
||||
return callstack2()
|
||||
|
@ -37,14 +30,9 @@ func TestStacktrace(t *testing.T) {
|
|||
stack: callstack1(),
|
||||
}
|
||||
|
||||
expect := "err msg"
|
||||
expected := "err msg"
|
||||
actual := fmt.Sprintf("%s", err)
|
||||
if expect != actual {
|
||||
t.Fatalf("expected formatted trace error message to be: %s, but got %s", expect, actual)
|
||||
}
|
||||
|
||||
actual = trimLineSpaces(fmt.Sprintf("%+v", err))
|
||||
if strings.Index(actual, "stacktrace_test.go") == -1 {
|
||||
t.Fatalf("does not have stacktrace in actual: %s", actual)
|
||||
}
|
||||
assert.Equal(t, expected, actual)
|
||||
assert.NotContains(t, actual, "stacktrace_test.go")
|
||||
}
|
||||
|
|
|
@ -545,11 +545,13 @@ func (s *suiteContext) theRenderOutputWillBe(docstring *messages.PickleStepArgum
|
|||
suiteCtxReg := regexp.MustCompile(`suite_context.go:\d+`)
|
||||
suiteCtxFuncReg := regexp.MustCompile(`github.com/cucumber/godog.SuiteContext.func(\d+)`)
|
||||
|
||||
expected := trimAllLines(strings.TrimSpace(docstring.Content))
|
||||
expected := docstring.Content
|
||||
expected = trimAllLines(expected)
|
||||
expected = suiteCtxReg.ReplaceAllString(expected, "suite_context.go:0")
|
||||
expected = suiteCtxFuncReg.ReplaceAllString(expected, "SuiteContext.func$1")
|
||||
|
||||
actual := trimAllLines(strings.TrimSpace(s.out.String()))
|
||||
actual := s.out.String()
|
||||
actual = trimAllLines(actual)
|
||||
actual = suiteCtxReg.ReplaceAllString(actual, "suite_context.go:0")
|
||||
actual = suiteCtxFuncReg.ReplaceAllString(actual, "SuiteContext.func$1")
|
||||
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче