-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathstats.go
More file actions
57 lines (46 loc) · 1 KB
/
stats.go
File metadata and controls
57 lines (46 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package suite
import "time"
// SuiteInformation stats stores stats for the whole suite execution.
type SuiteInformation struct {
Start, End time.Time
TestStats map[string]*TestInformation
}
// TestInformation stores information about the execution of each test.
type TestInformation struct {
TestName string
Start, End time.Time
Passed bool
}
func newSuiteInformation() *SuiteInformation {
return &SuiteInformation{
TestStats: make(map[string]*TestInformation),
}
}
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) {
if s == nil {
return
}
testStats, started := s.TestStats[testName]
if !started {
return
}
testStats.End = time.Now()
testStats.Passed = passed
}
func (s *SuiteInformation) Passed() bool {
for _, stats := range s.TestStats {
if !stats.Passed {
return false
}
}
return true
}