File tree Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -16,26 +16,30 @@ type TestInformation struct {
1616}
1717
1818func newSuiteInformation () * SuiteInformation {
19- testStats := make (map [string ]* TestInformation )
20-
2119 return & SuiteInformation {
22- TestStats : testStats ,
20+ TestStats : make ( map [ string ] * TestInformation ) ,
2321 }
2422}
2523
26- func (s SuiteInformation ) start (testName string ) {
24+ func (s * SuiteInformation ) start (testName string ) {
25+ if s == nil {
26+ return
27+ }
2728 s .TestStats [testName ] = & TestInformation {
2829 TestName : testName ,
2930 Start : time .Now (),
3031 }
3132}
3233
33- func (s SuiteInformation ) end (testName string , passed bool ) {
34+ func (s * SuiteInformation ) end (testName string , passed bool ) {
35+ if s == nil {
36+ return
37+ }
3438 s .TestStats [testName ].End = time .Now ()
3539 s .TestStats [testName ].Passed = passed
3640}
3741
38- func (s SuiteInformation ) Passed () bool {
42+ func (s * SuiteInformation ) Passed () bool {
3943 for _ , stats := range s .TestStats {
4044 if ! stats .Passed {
4145 return false
Original file line number Diff line number Diff line change @@ -161,10 +161,7 @@ func Run(t *testing.T, suite TestingSuite) {
161161
162162 r := recover ()
163163
164- if stats != nil {
165- passed := ! t .Failed () && r == nil
166- stats .end (method .Name , passed )
167- }
164+ stats .end (method .Name , ! t .Failed () && r == nil )
168165
169166 if afterTestSuite , ok := suite .(AfterTest ); ok {
170167 afterTestSuite .AfterTest (suiteName , method .Name )
@@ -185,9 +182,7 @@ func Run(t *testing.T, suite TestingSuite) {
185182 beforeTestSuite .BeforeTest (methodFinder .Elem ().Name (), method .Name )
186183 }
187184
188- if stats != nil {
189- stats .start (method .Name )
190- }
185+ stats .start (method .Name )
191186
192187 method .Func .Call ([]reflect.Value {reflect .ValueOf (suite )})
193188 },
You can’t perform that action at this time.
0 commit comments