From dc8c9c43787b389d86f4548796734a47bd6ac25e Mon Sep 17 00:00:00 2001 From: Tomohiko Himura Date: Mon, 3 Apr 2023 23:05:05 +0900 Subject: [PATCH] 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 --- run_test.go | 4 ++++ suite.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/run_test.go b/run_test.go index 874d014..94f7174 100644 --- a/run_test.go +++ b/run_test.go @@ -100,6 +100,7 @@ func Test_FailsOrPassesBasedOnStrictModeWhenHasPendingSteps(t *testing.T) { ctx.Step(`^one$`, func() error { return nil }) ctx.Step(`^two$`, func() error { return ErrPending }) }, + testingT: t, } r.storage = storage.NewStorage() @@ -109,10 +110,13 @@ func Test_FailsOrPassesBasedOnStrictModeWhenHasPendingSteps(t *testing.T) { } failed := r.concurrent(1) + require.False(t, r.testingT.Failed()) require.False(t, failed) assert.Equal(t, 1, beforeScenarioFired) assert.Equal(t, 1, afterScenarioFired) + // avoid t is Failed because this testcase Failed + r.testingT = nil r.strict = true failed = r.concurrent(1) require.True(t, failed) diff --git a/suite.go b/suite.go index 5321427..dc63013 100644 --- a/suite.go +++ b/suite.go @@ -468,7 +468,7 @@ func (s *suite) runPickle(pickle *messages.Pickle) (err error) { // Running scenario as a subtest. s.testingT.Run(pickle.Name, func(t *testing.T) { ctx, err = s.runSteps(ctx, pickle, pickle.Steps) - if err != nil { + if s.shouldFail(err) { t.Error(err) } })