Result of testing.T respect strict option (#539)
* test: testing.T.Failed should be false when strict is false and has pending steps * fix: testing.T respect strict option
Этот коммит содержится в:
родитель
6ce2b8696b
коммит
dc8c9c4378
2 изменённых файлов: 5 добавлений и 1 удалений
|
@ -100,6 +100,7 @@ func Test_FailsOrPassesBasedOnStrictModeWhenHasPendingSteps(t *testing.T) {
|
||||||
ctx.Step(`^one$`, func() error { return nil })
|
ctx.Step(`^one$`, func() error { return nil })
|
||||||
ctx.Step(`^two$`, func() error { return ErrPending })
|
ctx.Step(`^two$`, func() error { return ErrPending })
|
||||||
},
|
},
|
||||||
|
testingT: t,
|
||||||
}
|
}
|
||||||
|
|
||||||
r.storage = storage.NewStorage()
|
r.storage = storage.NewStorage()
|
||||||
|
@ -109,10 +110,13 @@ func Test_FailsOrPassesBasedOnStrictModeWhenHasPendingSteps(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
failed := r.concurrent(1)
|
failed := r.concurrent(1)
|
||||||
|
require.False(t, r.testingT.Failed())
|
||||||
require.False(t, failed)
|
require.False(t, failed)
|
||||||
assert.Equal(t, 1, beforeScenarioFired)
|
assert.Equal(t, 1, beforeScenarioFired)
|
||||||
assert.Equal(t, 1, afterScenarioFired)
|
assert.Equal(t, 1, afterScenarioFired)
|
||||||
|
|
||||||
|
// avoid t is Failed because this testcase Failed
|
||||||
|
r.testingT = nil
|
||||||
r.strict = true
|
r.strict = true
|
||||||
failed = r.concurrent(1)
|
failed = r.concurrent(1)
|
||||||
require.True(t, failed)
|
require.True(t, failed)
|
||||||
|
|
2
suite.go
2
suite.go
|
@ -468,7 +468,7 @@ func (s *suite) runPickle(pickle *messages.Pickle) (err error) {
|
||||||
// Running scenario as a subtest.
|
// Running scenario as a subtest.
|
||||||
s.testingT.Run(pickle.Name, func(t *testing.T) {
|
s.testingT.Run(pickle.Name, func(t *testing.T) {
|
||||||
ctx, err = s.runSteps(ctx, pickle, pickle.Steps)
|
ctx, err = s.runSteps(ctx, pickle, pickle.Steps)
|
||||||
if err != nil {
|
if s.shouldFail(err) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче