testing

package
v1.0.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2021 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

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

type ScenarioFn func(t *T) RunFn

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 NewT

func NewT(iter, scenarioName string) (*T, func())

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) Error added in v1.0.23

func (t *T) Error(err error)

Error is equivalent to Log followed by Fail.

func (*T) Errorf

func (t *T) Errorf(format string, args ...interface{})

Errorf is equivalent to Logf followed by Fail.

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) Failed added in v1.0.23

func (t *T) Failed() bool

Failed reports whether the function has failed.

func (*T) Fatal added in v1.0.23

func (t *T) Fatal(err error)

Fatal is equivalent to Log followed by FailNow.

func (*T) Fatalf added in v1.0.23

func (t *T) Fatalf(format string, args ...interface{})

Fatalf is equivalent to Logf followed by FailNow.

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

func (t *T) Logf(format string, args ...interface{})

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) Name added in v1.0.23

func (t *T) Name() string

Name returns the name of the running Scenario.

func (*T) Time

func (t *T) Time(stageName string, f func())

Time records a metric for the duration of the given function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL