gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

stats.go (941B)


      1 package suite
      2 
      3 import "time"
      4 
      5 // SuiteInformation stats stores stats for the whole suite execution.
      6 type SuiteInformation struct {
      7 	Start, End time.Time
      8 	TestStats  map[string]*TestInformation
      9 }
     10 
     11 // TestInformation stores information about the execution of each test.
     12 type TestInformation struct {
     13 	TestName   string
     14 	Start, End time.Time
     15 	Passed     bool
     16 }
     17 
     18 func newSuiteInformation() *SuiteInformation {
     19 	testStats := make(map[string]*TestInformation)
     20 
     21 	return &SuiteInformation{
     22 		TestStats: testStats,
     23 	}
     24 }
     25 
     26 func (s SuiteInformation) start(testName string) {
     27 	s.TestStats[testName] = &TestInformation{
     28 		TestName: testName,
     29 		Start:    time.Now(),
     30 	}
     31 }
     32 
     33 func (s SuiteInformation) end(testName string, passed bool) {
     34 	s.TestStats[testName].End = time.Now()
     35 	s.TestStats[testName].Passed = passed
     36 }
     37 
     38 func (s SuiteInformation) Passed() bool {
     39 	for _, stats := range s.TestStats {
     40 		if !stats.Passed {
     41 			return false
     42 		}
     43 	}
     44 
     45 	return true
     46 }