From bd0f5796c41ee33ec6fb57d874c065b7a0db57f7 Mon Sep 17 00:00:00 2001 From: Linus Barth Date: Tue, 10 Oct 2023 17:34:38 +0200 Subject: [PATCH] test: testing.T correctness in subtests setup/teardown --- suite/suite_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/suite/suite_test.go b/suite/suite_test.go index 788d3648b..68263e01c 100644 --- a/suite/suite_test.go +++ b/suite/suite_test.go @@ -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() { @@ -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 {