testing

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TESTING_LOG_REGEX = regexp.MustCompile(`(?m)^ {4}(?P<file>[\w\/\.]+):(?P<line>\d+): (?P<message>(.*\n {8}.*)*.*)`)
)

Functions

func Init

func Init(m *testing.M)

Initialize the testing instrumentation

func PanicAllRunningTests added in v0.1.13

func PanicAllRunningTests(e interface{}, skip int)

Fails and write panic on running tests Use this only if the process is going to crash

func PatchTestingLogger

func PatchTestingLogger()

func StartBenchmark

func StartBenchmark(b *testing.B, pc uintptr, benchFunc func(b *testing.B))

Starts a new benchmark using a pc as caller

func UnpatchTestingLogger

func UnpatchTestingLogger()

Types

type Benchmark

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

func GetBenchmark

func GetBenchmark(b *testing.B) *Benchmark

Gets the Benchmark struct from *testing.Benchmark

func (*Benchmark) Run

func (bench *Benchmark) Run(name string, f func(b *testing.B)) bool

Runs an auto instrumented sub benchmark

type Option

type Option func(*Test)

func WithContext

func WithContext(ctx context.Context) Option

Options for starting a new test

type Test

type Test struct {
	testing.TB
	// contains filtered or unexported fields
}

func GetTest

func GetTest(t *testing.T) *Test

Gets the Test struct from testing.T

func StartTest

func StartTest(t *testing.T, opts ...Option) *Test

Starts a new test

func StartTestFromCaller

func StartTestFromCaller(t *testing.T, pc uintptr, opts ...Option) *Test

Starts a new test with and uses the caller pc info for Name and Suite

func (*Test) Context

func (test *Test) Context() context.Context

Gets the test context

func (*Test) End

func (test *Test) End()

Ends the current test

func (*Test) Error

func (test *Test) Error(args ...interface{})

func (*Test) Errorf

func (test *Test) Errorf(format string, args ...interface{})

func (*Test) Fail

func (test *Test) Fail()

func (*Test) FailNow

func (test *Test) FailNow()

func (*Test) Failed

func (test *Test) Failed() bool

func (*Test) Fatal

func (test *Test) Fatal(args ...interface{})

func (*Test) Fatalf

func (test *Test) Fatalf(format string, args ...interface{})

func (*Test) Helper deprecated

func (test *Test) Helper()

Deprecated: use `testing.T.Helper` instead

func (*Test) Log

func (test *Test) Log(args ...interface{})

func (*Test) LogPanic added in v0.1.13

func (test *Test) LogPanic(recoverData interface{}, skipFrames int)

Log panic data with stacktrace

func (*Test) Logf

func (test *Test) Logf(format string, args ...interface{})

func (*Test) Name

func (test *Test) Name() string

func (*Test) Run

func (test *Test) Run(name string, f func(t *testing.T)) bool

Runs an auto instrumented sub test

func (*Test) SetTestCode added in v0.2.0

func (test *Test) SetTestCode(pc uintptr)

Set test code

func (*Test) Skip

func (test *Test) Skip(args ...interface{})

func (*Test) SkipNow

func (test *Test) SkipNow()

func (*Test) Skipf

func (test *Test) Skipf(format string, args ...interface{})

func (*Test) Skipped

func (test *Test) Skipped() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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