Skip to content

Commit

Permalink
Result of testing.T respect strict option (#539)
Browse files Browse the repository at this point in the history
* test: testing.T.Failed should be false when strict is false and has pending steps

* fix: testing.T respect strict option
  • Loading branch information
eiel authored Apr 3, 2023
1 parent 6ce2b86 commit dc8c9c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
Expand Down

0 comments on commit dc8c9c4

Please sign in to comment.