mock

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run added in v1.3.1

func Run(_ string, f func(*T))

Run initializes an environment that mimics a test function.

Types

type ErrFailNow

type ErrFailNow struct{}

ErrFailNow is the type used in panics to abort a test when users call FailNow.

type T

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

T is a type passed to Test functions to manage test state and support formatted test logs. A minimal mock of testing.T.

func NewT

func NewT() *T

NewT returns a newly constructed T.

func (*T) CheckFailed

func (m *T) CheckFailed(t *testing.T, fatal bool)

CheckFailed verifies that a mock test failed, otherwise it logs the test failure.

func (*T) CheckSucceeded

func (m *T) CheckSucceeded(t *testing.T)

CheckSucceeded verifies that a mock test succeeded, otherwise it logs the failure.

func (*T) Errorf

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

Errorf is equivalent to Logf followed by Fail.

func (*T) Fail

func (m *T) Fail()

Fail marks the function as having failed but continues execution.

func (*T) FailNow

func (m *T) FailNow()

FailNow marks the function as having failed.

Depending on the mode, it may either terminate further tests by panicking or it may not. To get termination, use the function Run. Otherwise, fatal errors are simply recorded.

func (*T) Fatalf

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

Fatalf is equivalent to Logf followed by FailNow.

func (*T) Helper

func (m *T) Helper()

Helper marks the calling function as a test helper function. This is a no-op for the mock.

func (*T) Logf

func (m *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.

func (*T) Reset added in v1.4.0

func (m *T) Reset()

Reset returns the state of the test object to as if it was just initialized.

func (*T) Text

func (m *T) Text() string

Text returns the error log for the test.

Jump to

Keyboard shortcuts

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