mirror of https://github.com/stretchr/testify.git
Don't setup suite if no methods satisfy filter
When suite setup is long, the necessity to wait for all suite setups for testing one single method bothers a lot. Here's a little fix of that behavior.pull/731/head
parent
363ebb24d0
commit
3efd733edb
|
@ -82,14 +82,7 @@ func Run(t *testing.T, suite TestingSuite) {
|
||||||
suite.SetT(t)
|
suite.SetT(t)
|
||||||
defer failOnPanic(t)
|
defer failOnPanic(t)
|
||||||
|
|
||||||
if setupAllSuite, ok := suite.(SetupAllSuite); ok {
|
setupDone := false
|
||||||
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{}
|
||||||
|
@ -100,7 +93,20 @@ func Run(t *testing.T, suite TestingSuite) {
|
||||||
fmt.Fprintf(os.Stderr, "testify: invalid regexp for -m: %s\n", err)
|
fmt.Fprintf(os.Stderr, "testify: invalid regexp for -m: %s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if ok {
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !setupDone {
|
||||||
|
if setupAllSuite, ok := suite.(SetupAllSuite); ok {
|
||||||
|
setupAllSuite.SetupSuite()
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if tearDownAllSuite, ok := suite.(TearDownAllSuite); ok {
|
||||||
|
tearDownAllSuite.TearDownSuite()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
setupDone = true
|
||||||
|
}
|
||||||
test := testing.InternalTest{
|
test := testing.InternalTest{
|
||||||
Name: method.Name,
|
Name: method.Name,
|
||||||
F: func(t *testing.T) {
|
F: func(t *testing.T) {
|
||||||
|
@ -128,7 +134,6 @@ func Run(t *testing.T, suite TestingSuite) {
|
||||||
}
|
}
|
||||||
tests = append(tests, test)
|
tests = append(tests, test)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
runTests(t, tests)
|
runTests(t, tests)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue