File: test_result.go

package info (click to toggle)
golang-github-leanovate-gopter 0.2.9%2Bgit20210201.bbbf00e-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 696 kB
  • sloc: makefile: 37
file content (52 lines) | stat: -rw-r--r-- 1,171 bytes parent folder | download
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
package gopter

import "time"

type testStatus int

const (
	// TestPassed indicates that the property check has passed.
	TestPassed testStatus = iota
	// TestProved indicates that the property has been proved.
	TestProved
	// TestFailed indicates that the property check has failed.
	TestFailed
	// TestExhausted indicates that the property check has exhausted, i.e. the generators have
	// generated too many empty results.
	TestExhausted
	// TestError indicates that the property check has finished with an error.
	TestError
)

func (s testStatus) String() string {
	switch s {
	case TestPassed:
		return "PASSED"
	case TestProved:
		return "PROVED"
	case TestFailed:
		return "FAILED"
	case TestExhausted:
		return "EXHAUSTED"
	case TestError:
		return "ERROR"
	}
	return ""
}

// TestResult contains the result of a property property check.
type TestResult struct {
	Status     testStatus
	Succeeded  int
	Discarded  int
	Labels     []string
	Error      error
	ErrorStack []byte
	Args       PropArgs
	Time       time.Duration
}

// Passed checks if the check has passed
func (r *TestResult) Passed() bool {
	return r.Status == TestPassed || r.Status == TestProved
}