Skip to content

Commit

Permalink
test: testing.T correctness in subtests setup/teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
Linus Barth authored and dolmen committed Oct 15, 2023
1 parent be9b75b commit 7d0eaf9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions suite/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ func (suite *SuiteTester) TestSubtest() {
for _, t := range []struct {
testName string
}{
{"first"},
{"second"},
{"first-subtest"},
{"second-subtest"},
} {
suiteT := suite.T()
suite.Run(t.testName, func() {
Expand All @@ -259,10 +259,14 @@ func (suite *SuiteTester) TestSubtest() {

func (suite *SuiteTester) TearDownSubTest() {
suite.TearDownSubTestRunCount++
// We should get the *testing.T for the test that is to be torn down
suite.Contains(suite.T().Name(), "subtest")
}

func (suite *SuiteTester) SetupSubTest() {
suite.SetupSubTestRunCount++
// We should get the *testing.T for the test that is to be set up
suite.Contains(suite.T().Name(), "subtest")
}

type SuiteSkipTester struct {
Expand Down

0 comments on commit 7d0eaf9

Please sign in to comment.