1
0
mirror of https://github.com/stretchr/testify.git synced 2025-04-28 05:33:12 +00:00

Defer suite teardown to align with test teardown

This commit is contained in:
Jon Gjengset 2014-11-25 19:58:50 -05:00
parent 576f6382c0
commit 81a69ed105

@ -39,6 +39,11 @@ func Run(t *testing.T, suite TestingSuite) {
if setupAllSuite, ok := suite.(SetupAllSuite); ok { if setupAllSuite, ok := suite.(SetupAllSuite); ok {
setupAllSuite.SetupSuite() setupAllSuite.SetupSuite()
} }
defer func() {
if tearDownAllSuite, ok := suite.(TearDownAllSuite); ok {
tearDownAllSuite.TearDownSuite()
}
}()
methodFinder := reflect.TypeOf(suite) methodFinder := reflect.TypeOf(suite)
tests := []testing.InternalTest{} tests := []testing.InternalTest{}
@ -75,10 +80,6 @@ func Run(t *testing.T, suite TestingSuite) {
tests) { tests) {
t.Fail() t.Fail()
} }
if tearDownAllSuite, ok := suite.(TearDownAllSuite); ok {
tearDownAllSuite.TearDownSuite()
}
} }
// Filtering method according to set regular expression // Filtering method according to set regular expression