harness
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeCleanable¶
type Cleanable interface {Runnable// Cleanup should clean up any lingering resources from the test.Cleanup(ctxcontext.Context, idstring)error}
Cleanable is an optional extension to Runnable that allows for post-testcleanup.
typeConcurrentExecutionStrategy¶
type ConcurrentExecutionStrategy struct{}
ConcurrentExecutionStrategy executes all test runs concurrently without anyregard for parallelism.
typeExecutionStrategy¶
type ExecutionStrategy interface {// Execute calls each function in whatever way the strategy wants. All// errors returned from the function should be wrapped and returned, but all// given functions must be executed.Run(ctxcontext.Context, fns []TestFn) ([]error,error)}
ExecutionStrategy defines how a TestHarness should execute a set of runs. Itessentially defines the concurrency model for a given testing session.
typeLinearExecutionStrategy¶
type LinearExecutionStrategy struct{}
LinearExecutionStrategy executes all test runs in a linear fashion, one afterthe other.
typeParallelExecutionStrategy¶
type ParallelExecutionStrategy struct {Limitint}
ParallelExecutionStrategy executes all test runs concurrently, but limits thenumber of concurrent runs to the given limit.
typeResults¶
type Results struct {TotalRunsint `json:"total_runs"`TotalPassint `json:"total_pass"`TotalFailint `json:"total_fail"`Elapsedhttpapi.Duration `json:"elapsed"`ElapsedMSint64 `json:"elapsed_ms"`Runs map[string]RunResult `json:"runs"`}
Results is the full compiled results for a set of test runs.
typeRunResult¶
type RunResult struct {FullIDstring `json:"full_id"`TestNamestring `json:"test_name"`IDstring `json:"id"`Logsstring `json:"logs"`Errorerror `json:"error"`StartedAttime.Time `json:"started_at"`Durationhttpapi.Duration `json:"duration"`DurationMSint64 `json:"duration_ms"`}
RunResult is the result of a single test run.
typeRunnable¶
type Runnable interface {// Run should use the passed context to handle cancellation and deadlines// properly, and should only return once the test has been fully completed// (no lingering goroutines, unless they are cleaned up by the accompanying// cleanup function).//// The test ID (part after the slash) is passed for identification if// necessary, and the provided logs write should be used for writing// whatever may be necessary for debugging the test.Run(ctxcontext.Context, idstring, logsio.Writer)error}
Runnable is a test interface that can be executed by a TestHarness.
typeShuffleExecutionStrategyWrapper¶
type ShuffleExecutionStrategyWrapper struct {InnerExecutionStrategy}
ShuffleExecutionStrategyWrapper is an ExecutionStrategy that wraps anotherExecutionStrategy and shuffles the order of the test runs before executing.
typeTestHarness¶
type TestHarness struct {// contains filtered or unexported fields}
TestHarness runs a bunch of registered test runs using the given executionstrategies.
funcNewTestHarness¶
func NewTestHarness(runStrategy, cleanupStrategyExecutionStrategy) *TestHarness
NewTestHarness creates a new TestHarness with the given execution strategies.
func (*TestHarness)AddRun¶
func (h *TestHarness) AddRun(testNamestring, idstring, runnerRunnable) *TestRun
AddRun creates a new *TestRun with the given name, ID and Runnable, adds itto the harness and returns it. Panics if the harness has been started, or atest with the given run.FullID() is already registered.
This is a convenience method that calls NewTestRun() and h.RegisterRun().
func (*TestHarness)Cleanup¶
func (h *TestHarness) Cleanup(ctxcontext.Context) (errerror)
Cleanup should be called after the test run has finished and results havebeen collected.
func (*TestHarness)RegisterRun¶
func (h *TestHarness) RegisterRun(run *TestRun)
RegisterRun registers the given *TestRun with the harness. Panics if theharness has been started, or a test with the given run.FullID() is alreadyregistered.
func (*TestHarness)Results¶
func (h *TestHarness) Results()Results
Results collates the results of all the test runs and returns them.
func (*TestHarness)Run¶
func (h *TestHarness) Run(ctxcontext.Context) (errerror)
Run runs the registered tests using the given ExecutionStrategy. The providedcontext can be used to cancel or set a deadline for the test run. Blocksuntil the tests have finished and returns the test execution error (notindividual run errors).
Panics if called more than once.
typeTestRun¶
type TestRun struct {// contains filtered or unexported fields}
TestRun is a single test run and it's accompanying state.
typeTimeoutExecutionStrategyWrapper¶
type TimeoutExecutionStrategyWrapper struct {Timeouttime.DurationInnerExecutionStrategy}
TimeoutExecutionStrategyWrapper is an ExecutionStrategy that wraps anotherExecutionStrategy and applies a timeout to each test run's context.