Documentation ¶
Index ¶
- 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) Name() string
- func (t *T) Time(stageName string, f func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 ¶ added in v1.0.21
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 // Logger with user and iteration tags Logger *log.Logger Require *require.Assertions 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 ¶ added in v1.0.21
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 ¶ added in v1.0.23
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.