-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
bughacktoberfest-acceptedHacktoberfestHacktoberfestpkg-suiteChange related to package testify/suiteChange related to package testify/suite
Description
package main
import (
"fmt"
"testing"
"github.com/stretchr/testify/suite"
)
type Suite struct {
suite.Suite
}
func TestXX(t *testing.T) {
suite.Run(t, new(Suite))
}
func (s *Suite) SetupSuite() {
fmt.Println("In SetupSuite")
}
func (s *Suite) TearDownSuite() {
fmt.Println("In TearDownSuite")
}
func (s *Suite) TestXX_YY() {
s.Run("test xx yy", func() {
panic("test")
})
}
For the above snippet, it panics in subtest and does not enter the TearDownSuite, should we add failOnPanic in the subtests? like this:
func (suite *Suite) Run(name string, subtest func()) bool {
oldT := suite.T()
defer suite.SetT(oldT)
return oldT.Run(name, func(t *testing.T) {
+ defer failOnPanic(t)
suite.SetT(t)
subtest()
})
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bughacktoberfest-acceptedHacktoberfestHacktoberfestpkg-suiteChange related to package testify/suiteChange related to package testify/suite