Documentation ¶
Overview ¶
The `model`s package is very atypical for projects written in go, but unfortunately cannot be avoided as it helps to avoid cyclic dependencies. Types required by a library user such as `TestFunc` are reexported by the handoff package.
Index ¶
- type NotFoundError
- type Result
- type RunParams
- type TB
- type TestContext
- type TestFunc
- type TestRun
- type TestRunHTTP
- type TestSuite
- type TestSuiteRun
- func (tsr TestSuiteRun) IsFlaky() bool
- func (tsr TestSuiteRun) LatestTestAttempt(testName string) *TestRun
- func (tsr TestSuiteRun) LatestTestAttempts() map[string]*TestRun
- func (tsr TestSuiteRun) PendingTests() []*TestRun
- func (tsr TestSuiteRun) ResultFromTestResults() Result
- func (t TestSuiteRun) ShouldRetry(tr TestRun) bool
- func (tsr TestSuiteRun) TestSuiteDuration() int64
- type TestSuiteRunHTTP
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NotFoundError ¶
type NotFoundError struct{}
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type RunParams ¶
type RunParams struct { // TriggeredBy denotes the origin of the test run, e.g. scheduled or via http call. TriggeredBy string // Reference can be set when starting a new test suite run to identify // a test run by a user provided value. Reference string MaxTestAttempts int Timeout time.Duration // TestFilter filters out a subset of the tests and skips the remaining ones. TestFilter *regexp.Regexp }
type TB ¶
type TB interface { Cleanup(func()) Error(args ...any) Errorf(format string, args ...any) Fail() FailNow() Failed() bool Fatal(args ...any) Fatalf(format string, args ...any) Helper() Log(args ...any) Logf(format string, args ...any) Name() string Setenv(key, value string) Skip(args ...any) SkipNow() Skipf(format string, args ...any) Skipped() bool TempDir() string /* Handoff specific */ SoftFailure() Attempt() int }
TB is a carbon copy of the stdlib testing.TB interface + some custom handoff functions. Unfortunately we cannot reuse the original testing.TB interface because it deliberately includes the `private()` function to prevent others from implementing it to allow them to add new functions over time without breaking anything.
type TestContext ¶
func (TestContext) Merge ¶
func (c TestContext) Merge(c2 TestContext)
type TestRun ¶
type TestRun struct { SuiteName string `json:"suiteName"` SuiteRunID int `json:"suiteRunId"` Name string `json:"name"` // Result is the outcome of the test run. Result Result `json:"result"` // Test run attempt counter Attempt int `json:"attempt"` // SoftFailure if set to true, does not fail a test suite when the test run fails. SoftFailure bool `json:"softFailure"` // Logs contains log messages written by the test itself. Logs string `json:"logs"` // Start marks the start time of the test run. Start time.Time `json:"start"` // End marks the end time of the test run. End time.Time `json:"end"` // DurationInMS is the duration of the test run in milliseconds (end-start). DurationInMS int64 `json:"durationInMs"` // Context contains additional testrun specific information that is collected during and // after a test run either by the test itself (`t.SetContext`) or via plugins. This can // e.g. contain correlation ids or links to external services that may help debugging a test run // (among other things). Context TestContext `json:"context"` }
func (TestRun) NewAttempt ¶
type TestRunHTTP ¶
type TestRunHTTP struct { SuiteName string `json:"suiteName"` SuiteRunID int `json:"suiteRunId"` Name string `json:"name"` // Result is the outcome of the test run. Result Result `json:"result"` // Test run attempt counter Attempt int `json:"attempt"` // SoftFailure if set to true, does not fail a test suite when the test run fails. SoftFailure bool `json:"softFailure"` // Logs contains log messages written by the test itself. Logs string `json:"logs"` // Start marks the start time of the test run. Start time.Time `json:"start"` // End marks the end time of the test run. End time.Time `json:"end"` // DurationInMS is the duration of the test run in milliseconds (end-start). DurationInMS int64 `json:"durationInMs"` // Context contains additional testrun specific information that is collected during and // after a test run either by the test itself (`t.SetContext`) or via plugins. This can // e.g. contain correlation ids or links to external services that may help debugging a test run // (among other things). Context TestContext `json:"context"` }
type TestSuite ¶
type TestSuite struct { // Name of the testsuite Name string `json:"name"` // TestRetries is the amount of times a test is retried when failing. MaxTestAttempts int // Namespace allows grouping of test suites, e.g. by team name. Namespace string Setup func() error Teardown func() error Tests map[string]TestFunc // contains filtered or unexported fields }
TestSuite is a static definition of a testsuite and contains Setup, Teardown and a collection of Test functions.
func (TestSuite) SafeTeardown ¶
type TestSuiteRun ¶
type TestSuiteRun struct { // ID is the identifier of the test run. ID int `json:"id"` // SuiteName is the name of the test suite that is run. SuiteName string `json:"suiteName"` // Result is the outcome of the entire test suite run. Result Result `json:"result"` // Tests counts the total amount of tests in the suite. Tests int `json:"tests"` // Flaky is set to true if one or more tests only succeed // after being retried. Flaky bool `json:"flaky"` // Params passed in to a run. Params RunParams `json:"params"` // Scheduled is the time when the test was triggered, e.g. // through a http call. Scheduled time.Time `json:"scheduled"` // Start is the time when the test run first started executing. Start time.Time `json:"start"` // End is the time when the test run finished executing. End time.Time `json:"end"` // DurationInMS is the test run execution times summed up. DurationInMS int64 `json:"durationInMs"` // SetupLogs are the logs that are written during the setup phase. SetupLogs string `json:"setupLogs"` // Environment is additional information on where the tests are run (e.g. cluster name). Environment string `json:"environment"` // TestResults contains the detailed test results of each test. TestResults []*TestRun `json:"testResults"` }
func (TestSuiteRun) IsFlaky ¶
func (tsr TestSuiteRun) IsFlaky() bool
func (TestSuiteRun) LatestTestAttempt ¶
func (tsr TestSuiteRun) LatestTestAttempt(testName string) *TestRun
func (TestSuiteRun) LatestTestAttempts ¶
func (tsr TestSuiteRun) LatestTestAttempts() map[string]*TestRun
func (TestSuiteRun) PendingTests ¶
func (tsr TestSuiteRun) PendingTests() []*TestRun
func (TestSuiteRun) ResultFromTestResults ¶
func (tsr TestSuiteRun) ResultFromTestResults() Result
func (TestSuiteRun) ShouldRetry ¶
func (t TestSuiteRun) ShouldRetry(tr TestRun) bool
func (TestSuiteRun) TestSuiteDuration ¶
func (tsr TestSuiteRun) TestSuiteDuration() int64
type TestSuiteRunHTTP ¶
type TestSuiteRunHTTP struct { // ID is the identifier of the test run. ID int `json:"id"` // SuiteName is the name of the test suite that is run. SuiteName string `json:"suiteName"` // Result is the outcome of the entire test suite run. Result Result `json:"result"` // TestFilter filters out a subset of the tests and skips the // remaining ones (not implemented yet). TestFilter string `json:"testFilter"` // Reference can be set when starting a new test suite run to identify // a test run by a user provided value. Reference string `json:"reference"` // Tests counts the total amount of tests in the suite. Tests int `json:"tests"` // Scheduled is the time when the test was triggered, e.g. // through a http call. Scheduled time.Time `json:"scheduled"` // Start is the time when the test run first started executing. Start time.Time `json:"start"` // End is the time when the test run finished executing. End time.Time `json:"end"` // DurationInMS is the test run execution times summed up. DurationInMS int64 `json:"durationInMs"` // SetupLogs are the logs that are written during the setup phase. SetupLogs string `json:"setupLogs"` // TriggeredBy denotes the origin of the test run, e.g. scheduled or via http call. TriggeredBy string `json:"triggeredBy"` // Environment is additional information on where the tests are run (e.g. cluster name). Environment string `json:"environment"` // TestResults contains the detailed test results of each test. TestResults []TestRunHTTP `json:"testResults"` }