Documentation ¶
Overview ¶
F1's testing package is analagous to Go's built-in testing package. It provides a "t" type which ise injected into setup and iteration run functions, which also provides some common testing functionality such as the ability to perform assertions.
Index ¶
- func CheckResults(t *T, done chan<- struct{})
- type RunFn
- type ScenarioFn
- type T
- func (t *T) Cleanup(f func())
- func (t *T) Error(err error)
- func (t *T) Errorf(format string, args ...interface{})
- func (t *T) Fail()
- func (t *T) FailNow()
- func (t *T) Failed() bool
- func (t *T) Fatal(err error)
- func (t *T) Fatalf(format string, args ...interface{})
- func (t *T) Log(args ...interface{})
- func (t *T) Logf(format string, args ...interface{})
- func (t *T) Logger() *log.Logger
- func (t *T) Name() string
- func (t *T) Require() *require.Assertions
- func (t *T) TeardownFailed() bool
- func (t *T) Time(stageName string, f func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResults ¶ added in v2.0.4
func CheckResults(t *T, done chan<- struct{})
Types ¶
type RunFn ¶
type RunFn func(t *T)
RunFn performs a single iteration of the scenario. 't' may be used for asserting results or failing the scenario.
type ScenarioFn ¶
ScenarioFn initialises a scenario and returns the iteration function (RunFn) to be invoked for every iteration of the tests.
type T ¶
type T struct { // "iteration " + iteration number or "setup" Iteration string Scenario string // contains filtered or unexported fields }
T is a type passed to Scenario functions to manage test state and support formatted test logs. A test ends when its Scenario function returns or calls any of the methods FailNow, Fatal, Fatalf. Those methods must be called only from the goroutine running the Scenario function. The other reporting methods, such as the variations of Log and Error, may be called simultaneously from multiple goroutines.
func (*T) Cleanup ¶
func (t *T) Cleanup(f func())
Cleanup registers a function to be called when the scenario or the iteration completes. Cleanup functions will be called in last added, first called order.
func (*T) Fail ¶
func (t *T) Fail()
Fail marks the function as having failed but continues execution.
func (*T) FailNow ¶
func (t *T) FailNow()
FailNow marks the function as having failed and stops its execution by calling runtime.Goexit (which then runs all deferred calls in the current goroutine). Execution will continue at the next Scenario iteration. FailNow must be called from the goroutine running the Scenario, not from other goroutines created during the Scenario. Calling FailNow does not stop those other goroutines.
func (*T) Log ¶
func (t *T) Log(args ...interface{})
Log formats its arguments using default formatting, analogous to Println, and records the text in the error log. The text will be printed only if f1 is running in verbose mode.
func (*T) Logf ¶
Logf formats its arguments according to the format, analogous to Printf, and records the text in the error log. A final newline is added if not provided. The text will be printed only if f1 is running in verbose mode.
func (*T) Require ¶
func (t *T) Require() *require.Assertions