github.com/leanovate/gopter@v0.2.9/test_result.go (about)

     1  package gopter
     2  
     3  import "time"
     4  
     5  type testStatus int
     6  
     7  const (
     8  	// TestPassed indicates that the property check has passed.
     9  	TestPassed testStatus = iota
    10  	// TestProved indicates that the property has been proved.
    11  	TestProved
    12  	// TestFailed indicates that the property check has failed.
    13  	TestFailed
    14  	// TestExhausted indicates that the property check has exhausted, i.e. the generators have
    15  	// generated too many empty results.
    16  	TestExhausted
    17  	// TestError indicates that the property check has finished with an error.
    18  	TestError
    19  )
    20  
    21  func (s testStatus) String() string {
    22  	switch s {
    23  	case TestPassed:
    24  		return "PASSED"
    25  	case TestProved:
    26  		return "PROVED"
    27  	case TestFailed:
    28  		return "FAILED"
    29  	case TestExhausted:
    30  		return "EXHAUSTED"
    31  	case TestError:
    32  		return "ERROR"
    33  	}
    34  	return ""
    35  }
    36  
    37  // TestResult contains the result of a property property check.
    38  type TestResult struct {
    39  	Status     testStatus
    40  	Succeeded  int
    41  	Discarded  int
    42  	Labels     []string
    43  	Error      error
    44  	ErrorStack []byte
    45  	Args       PropArgs
    46  	Time       time.Duration
    47  }
    48  
    49  // Passed checks if the check has passed
    50  func (r *TestResult) Passed() bool {
    51  	return r.Status == TestPassed || r.Status == TestProved
    52  }