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