test: testing.T correctness in subtests setup/teardown

pull/1423/head
Linus Barth 2023-10-16 02:59:16 +02:00 committed by Olivier Mengué
parent 82022eeb0d
commit 855d1c6784
1 changed files with 6 additions and 2 deletions

View File

@ -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 {