Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions suite/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@ type TestInformation struct {
}

func newSuiteInformation() *SuiteInformation {
testStats := make(map[string]*TestInformation)

return &SuiteInformation{
TestStats: testStats,
TestStats: make(map[string]*TestInformation),
}
}

func (s SuiteInformation) start(testName string) {
func (s *SuiteInformation) start(testName string) {
if s == nil {
return
}
s.TestStats[testName] = &TestInformation{
TestName: testName,
Start: time.Now(),
}
}

func (s SuiteInformation) end(testName string, passed bool) {
func (s *SuiteInformation) end(testName string, passed bool) {
if s == nil {
return
}
s.TestStats[testName].End = time.Now()
s.TestStats[testName].Passed = passed
}

func (s SuiteInformation) Passed() bool {
func (s *SuiteInformation) Passed() bool {
for _, stats := range s.TestStats {
if !stats.Passed {
return false
Expand Down
9 changes: 2 additions & 7 deletions suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ func Run(t *testing.T, suite TestingSuite) {

r := recover()

if stats != nil {
passed := !t.Failed() && r == nil
stats.end(method.Name, passed)
}
stats.end(method.Name, !t.Failed() && r == nil)

if afterTestSuite, ok := suite.(AfterTest); ok {
afterTestSuite.AfterTest(suiteName, method.Name)
Expand All @@ -185,9 +182,7 @@ func Run(t *testing.T, suite TestingSuite) {
beforeTestSuite.BeforeTest(methodFinder.Elem().Name(), method.Name)
}

if stats != nil {
stats.start(method.Name)
}
stats.start(method.Name)

method.Func.Call([]reflect.Value{reflect.ValueOf(suite)})
},
Expand Down