fixturez

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 9 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertNoError

func AssertNoError(t *testing.T, err error)

AssertNoError is like assert.NoError, with proper handling of github.com/ibrt/golang-errors errors.

func AssertNotPanics

func AssertNotPanics(t *testing.T, f func())

AssertNotPanics is like assert.NotPanics, with proper handling of github.com/ibrt/golang-errors errors.

func AssertPanicsWith added in v1.2.0

func AssertPanicsWith(t *testing.T, errStr string, f func())

AssertPanicsWith is like assert.PanicsWithError, with proper handling of github.com/ibrt/golang-errors errors.

func RequireNoError

func RequireNoError(t *testing.T, err error)

RequireNoError is like require.NoError, with proper handling of github.com/ibrt/golang-errors errors.

func RequireNotPanics

func RequireNotPanics(t *testing.T, f func())

RequireNotPanics is like require.NotPanics, with proper handling of github.com/ibrt/golang-errors errors.

func RequirePanicsWith added in v1.2.0

func RequirePanicsWith(t *testing.T, errStr string, f func())

RequirePanicsWith is like require.PanicsWithError, with proper handling of github.com/ibrt/golang-errors errors.

func RunSuite

func RunSuite(t *testing.T, s Suite)

RunSuite runs the test suite.

Types

type AfterSuite

type AfterSuite interface {
	AfterSuite(context.Context, *testing.T)
}

AfterSuite represents a method invoked after completing a test suite.

type AfterTest

type AfterTest interface {
	AfterTest(context.Context, *testing.T)
}

AfterTest represents a method invoked after each test method in a suite.

type BeforeSuite

type BeforeSuite interface {
	BeforeSuite(context.Context, *testing.T) context.Context
}

BeforeSuite describes a method invoked before starting a test suite.

type BeforeTest

type BeforeTest interface {
	BeforeTest(context.Context, *testing.T) context.Context
}

BeforeTest represents a method invoked before each test method in a suite.

type Config

type Config struct {
	// SkipWarnings indicates whether to print suite-generated warnings, e.g. a list of fields and methods on the suite
	// struct that are not considered helpers or test methods.
	SkipWarnings bool
	// Logf is the to be used to print suite-generated warnings. If unset, the suite defaults to `t.Logf`.
	Logf func(string, ...interface{})
}

Config allows to customize the behavior of the suite runner.

type DefaultConfigMixin

type DefaultConfigMixin struct {
}

DefaultConfigMixin implements the Suite interface returning a default config.

func (*DefaultConfigMixin) Suite

func (*DefaultConfigMixin) Suite() Config

Suite implements the Suite interface.

type OutputCapture added in v1.1.0

type OutputCapture struct {
	// contains filtered or unexported fields
}

OutputCapture can be used to capture standard output and standard error.

func CaptureOutput added in v1.1.0

func CaptureOutput() *OutputCapture

CaptureOutput captures the output in tests. Always defer OutputCapture.Close() right after CaptureOutput is called.

func (*OutputCapture) Close added in v1.1.0

func (c *OutputCapture) Close()

Close finalizes the capture by flushing/caching all buffers and restoring the original stdout/sterr.

func (*OutputCapture) GetErr added in v1.1.0

func (c *OutputCapture) GetErr() []byte

GetErr calls Close and returns the captured standard error.

func (*OutputCapture) GetErrString added in v1.1.0

func (c *OutputCapture) GetErrString() string

GetErrString calls Close and returns the captured standard error as string.

func (*OutputCapture) GetOut added in v1.1.0

func (c *OutputCapture) GetOut() []byte

GetOut calls Close and returns the captured standard output.

func (*OutputCapture) GetOutString added in v1.1.0

func (c *OutputCapture) GetOutString() string

GetOutString calls Close and returns the captured standard output as string.

type Suite

type Suite interface {
	Suite() Config
}

Suite describes a struct that can be used as test suite.

Jump to

Keyboard shortcuts

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