@@ -15,7 +15,6 @@ import (
1515 "github.com/stretchr/testify/require"
1616)
1717
18- var allTestsFilter = func (_ , _ string ) (bool , error ) { return true , nil }
1918var matchMethod = flag .String ("testify.m" , "" , "regular expression to select tests of the testify suite to run" )
2019
2120// Suite is a basic testing suite with methods for storing and
@@ -116,6 +115,11 @@ func (suite *Suite) Run(name string, subtest func()) bool {
116115 })
117116}
118117
118+ type test = struct {
119+ name string
120+ run func (t * testing.T )
121+ }
122+
119123// Run takes a testing suite and runs all of the tests attached
120124// to it.
121125func Run (t * testing.T , suite TestingSuite ) {
@@ -131,7 +135,7 @@ func Run(t *testing.T, suite TestingSuite) {
131135 stats = newSuiteInformation ()
132136 }
133137
134- tests := []testing. InternalTest {}
138+ var tests [] test
135139 methodFinder := reflect .TypeOf (suite )
136140 suiteName := methodFinder .Elem ().Name ()
137141
@@ -160,9 +164,9 @@ func Run(t *testing.T, suite TestingSuite) {
160164 suiteSetupDone = true
161165 }
162166
163- test := testing. InternalTest {
164- Name : method .Name ,
165- F : func (t * testing.T ) {
167+ test := test {
168+ name : method .Name ,
169+ run : func (t * testing.T ) {
166170 parentT := suite .T ()
167171 suite .SetT (t )
168172 defer recoverAndFailOnPanic (t )
@@ -229,25 +233,13 @@ func methodFilter(name string) (bool, error) {
229233 return regexp .MatchString (* matchMethod , name )
230234}
231235
232- func runTests (t testing.TB , tests []testing. InternalTest ) {
236+ func runTests (t * testing.T , tests []test ) {
233237 if len (tests ) == 0 {
234238 t .Log ("warning: no tests to run" )
235239 return
236240 }
237241
238- r , ok := t .(runner )
239- if ! ok { // backwards compatibility with Go 1.6 and below
240- if ! testing .RunTests (allTestsFilter , tests ) {
241- t .Fail ()
242- }
243- return
244- }
245-
246242 for _ , test := range tests {
247- r .Run (test .Name , test .F )
243+ t .Run (test .name , test .run )
248244 }
249245}
250-
251- type runner interface {
252- Run (name string , f func (t * testing.T )) bool
253- }
0 commit comments