Documentation ¶
Index ¶
- Variables
- func Debug(vs ...interface{})
- func DebugS(v interface{}, options ...Option) string
- func Debugln(vs ...interface{})
- func Fail(err error) error
- func InErrs(d error, ds ...error) (b bool)
- func Leak(t ErrorReporter) func()
- func LeakWithContext(ctx context.Context, t ErrorReporter) func()
- func LeakWithTimeout(t ErrorReporter, dur time.Duration) func()
- func MemStatsPrint()
- func Mock(args ...interface{})
- func MockBytes(min, max int) []byte
- func MockCheck(args ...bool)
- func MockDur(min, max time.Duration) time.Duration
- func MockInt(min, max int) int
- func MockRegister(fns ...interface{})
- func MockString(min, max int) string
- func Ok(err error) error
- func Rand(data ...interface{}) interface{}
- func RandS(strList ...string) string
- func Run(t *testing.T, tests ...Test)
- type B
- type ErrorReporter
- type Fixture
- type IBenchmark
- type Option
- type Printer
- type Test
Constants ¶
This section is empty.
Variables ¶
var ( ErrXTest = xerror.New("grpcTest error") ErrParamIsNil = ErrXTest.New("the parameter is nil") ErrFuncTimeout = ErrXTest.New("the func is timeout") ErrParamTypeNotFunc = ErrXTest.New("the type of the parameters is not func") ErrDurZero = ErrXTest.New("the duration time must more than zero") ErrInputParamsNotMatch = ErrXTest.New("the input params of func is not match") ErrInputOutputParamsNotMatch = ErrXTest.New("the input num and output num of the callback func is not match") ErrFuncOutputTypeNotMatch = ErrXTest.New("the output type of the callback func is not match") ErrForeachParameterNil = ErrXTest.New("the parameter of [Foreach] must not be nil") )
var DefaultPrinter = NewPrinter(os.Stdout, WithIndent(" "))
Default prints to os.Stdout with two space indentation.
var TickerInterval = time.Millisecond * 50
TickerInterval defines the interval used by the ticker in Check* functions.
Functions ¶
func Debug ¶ added in v0.2.0
func Debug(vs ...interface{})
Debug writes a representation of v to os.Stdout, separated by spaces.
func Debugln ¶ added in v0.2.0
func Debugln(vs ...interface{})
Debugln prints v to os.Stdout, one per line.
func Leak ¶ added in v0.2.0
func Leak(t ErrorReporter) func()
Leak snapshots the currently-running goroutines and returns a function to be run at the end of tests to see whether any goroutines leaked, waiting up to 5 seconds in error conditions
func LeakWithContext ¶ added in v0.2.0
func LeakWithContext(ctx context.Context, t ErrorReporter) func()
LeakWithContext is the same as Check, but uses a context.Context for cancellation and timeout control
func LeakWithTimeout ¶ added in v0.2.0
func LeakWithTimeout(t ErrorReporter, dur time.Duration) func()
LeakWithTimeout is the same as Check, but with a configurable timeout
func MemStatsPrint ¶ added in v0.2.0
func MemStatsPrint()
Types ¶
type ErrorReporter ¶ added in v0.1.12
type ErrorReporter interface {
Errorf(format string, args ...interface{})
}
ErrorReporter is a tiny subset of a testing.TB to make testing not such a massive pain
type Fixture ¶ added in v0.2.0
type Fixture struct { RunNum uint // contains filtered or unexported fields }
func (*Fixture) InitHandlerParam ¶ added in v0.2.0
type IBenchmark ¶ added in v0.2.0
type IBenchmark interface { CpuProfile(file string) IBenchmark MemProfile(file string) IBenchmark Do(fn func(b B)) IBenchmark String() string }
func Benchmark ¶ added in v0.1.8
func Benchmark(n int) IBenchmark
func BenchmarkParallel ¶ added in v0.1.12
func BenchmarkParallel(n int, m int) IBenchmark
BenchmarkParallel
type Option ¶ added in v0.1.13
type Option func(o *Printer)
An Option modifies the default behaviour of a Printer.
func AlwaysIncludeType ¶ added in v0.1.13
func AlwaysIncludeType() Option
AlwaysIncludeType always includes explicit type information for each item.
func WithHide ¶ added in v0.2.0
func WithHide(ts ...interface{}) Option
Hide excludes the given types from representation, instead just printing the name of the type.
func WithIgnoreGoStringer ¶ added in v0.2.0
func WithIgnoreGoStringer() Option
IgnoreGoStringer disables use of the .GoString() method.
func WithOmitEmpty ¶ added in v0.2.0
OmitEmpty sets whether empty field members should be omitted from output.
type Printer ¶ added in v0.1.13
type Printer struct {
// contains filtered or unexported fields
}
Printer represents structs in a printable manner.
func NewPrinter ¶ added in v0.2.0
New creates a new Printer on w with the given Fixture.