fix: panic behavior for subtests

This fix adds panic handling for subtests which will achieve:
- subtests will fail for the correct test context when panicking
- the test execution is not stopped; the next subtest will be executed
pull/1423/head
Linus Barth 2023-10-18 03:22:36 +02:00 committed by Olivier Mengué
parent 65318c364a
commit a4a54a4597
1 changed files with 2 additions and 1 deletions

View File

@ -98,9 +98,10 @@ func (suite *Suite) Run(name string, subtest func()) bool {
return oldT.Run(name, func(t *testing.T) {
suite.SetT(t)
defer suite.SetT(oldT)
defer recoverAndFailOnPanic(t)
if setupSubTest, ok := suite.s.(SetupSubTest); ok {
setupSubTest.SetupSubTest()
}