diff --git a/suite/suite.go b/suite/suite.go index 8d8ca2a..1b210fb 100644 --- a/suite/suite.go +++ b/suite/suite.go @@ -1,9 +1,9 @@ package suite import ( - "testing" "reflect" "regexp" + "testing" ) // Suite is a basic testing suite with methods for storing and @@ -32,19 +32,33 @@ func Run(t *testing.T, suite TestingSuite) { } methodFinder := reflect.TypeOf(suite) + tests := []testing.InternalTest{} for index := 0; index < methodFinder.NumMethod(); index++ { method := methodFinder.Method(index) if ok, _ := regexp.MatchString("^Test", method.Name); ok { - if setupTestSuite, ok := suite.(SetupTestSuite); ok { - setupTestSuite.SetupTest() - } - method.Func.Call([]reflect.Value{reflect.ValueOf(suite)}) - if tearDownTestSuite, ok := suite.(TearDownTestSuite); ok { - tearDownTestSuite.TearDownTest() + test := testing.InternalTest{ + Name: method.Name, + F: func(t *testing.T) { + suite.SetT(t) + if setupTestSuite, ok := suite.(SetupTestSuite); ok { + setupTestSuite.SetupTest() + } + method.Func.Call([]reflect.Value{reflect.ValueOf(suite)}) + if tearDownTestSuite, ok := suite.(TearDownTestSuite); ok { + tearDownTestSuite.TearDownTest() + } + }, } + tests = append(tests, test) } } + if !testing.RunTests(func(pat, str string) (bool, error) { + return true, nil + }, tests) { + t.Fail() + } + if tearDownAllSuite, ok := suite.(TearDownAllSuite); ok { tearDownAllSuite.TearDownSuite() }