Documentation
¶
Index ¶
- func CacheFlush()
- func CallerLocation(skip int, short bool) string
- func Log(logger interface{ ... }, args ...interface{})
- func Recover(fn func()) (panicValue interface{}, ok bool)
- func RecoverExceptGoexit(fn func())
- func RegisterCacheFlush(fn func()) struct{}
- func SetupCacheFlush(tb testing.TB)
- func SymbolicName(T interface{}) string
- type RecorderTB
- func (rtb *RecorderTB) Cleanup(f func())
- func (rtb *RecorderTB) CleanupNow()
- func (rtb *RecorderTB) Error(args ...interface{})
- func (rtb *RecorderTB) Errorf(format string, args ...interface{})
- func (rtb *RecorderTB) Fail()
- func (rtb *RecorderTB) FailNow()
- func (rtb *RecorderTB) Failed() bool
- func (rtb *RecorderTB) Fatal(args ...interface{})
- func (rtb *RecorderTB) Fatalf(format string, args ...interface{})
- func (rtb *RecorderTB) Forward()
- func (rtb *RecorderTB) Helper()
- func (rtb *RecorderTB) Log(args ...interface{})
- func (rtb *RecorderTB) Logf(format string, args ...interface{})
- func (rtb *RecorderTB) Run(_ string, blk func(testing.TB)) bool
- type StubTB
- func (m *StubTB) Cleanup(f func())
- func (m *StubTB) Error(args ...interface{})
- func (m *StubTB) Errorf(format string, args ...interface{})
- func (m *StubTB) Fail()
- func (m *StubTB) FailNow()
- func (m *StubTB) Failed() bool
- func (m *StubTB) Fatal(args ...interface{})
- func (m *StubTB) Fatalf(format string, args ...interface{})
- func (m *StubTB) Finish()
- func (m *StubTB) Helper()
- func (m *StubTB) Log(args ...interface{})
- func (m *StubTB) Logf(format string, args ...interface{})
- func (m *StubTB) Name() string
- func (m *StubTB) Skip(args ...interface{})
- func (m *StubTB) SkipNow()
- func (m *StubTB) Skipf(format string, args ...interface{})
- func (m *StubTB) Skipped() bool
- func (m *StubTB) TempDir() string
- type Teardown
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheFlush ¶ added in v0.34.2
func CacheFlush()
func CallerLocation ¶ added in v0.66.0
func Log ¶ added in v0.70.1
func Log(logger interface { Logf(format string, args ...interface{}) }, args ...interface{})
func RecoverExceptGoexit ¶ added in v0.60.0
func RecoverExceptGoexit(fn func())
func RegisterCacheFlush ¶ added in v0.34.2
func RegisterCacheFlush(fn func()) struct{}
func SetupCacheFlush ¶ added in v0.34.2
func SymbolicName ¶ added in v0.48.0
func SymbolicName(T interface{}) string
Types ¶
type RecorderTB ¶ added in v0.19.0
type RecorderTB struct { testing.TB IsFailed bool Config struct { Passthrough bool } // contains filtered or unexported fields }
func (*RecorderTB) Cleanup ¶ added in v0.19.0
func (rtb *RecorderTB) Cleanup(f func())
func (*RecorderTB) CleanupNow ¶ added in v0.23.0
func (rtb *RecorderTB) CleanupNow()
func (*RecorderTB) Error ¶ added in v0.19.0
func (rtb *RecorderTB) Error(args ...interface{})
func (*RecorderTB) Errorf ¶ added in v0.19.0
func (rtb *RecorderTB) Errorf(format string, args ...interface{})
func (*RecorderTB) Fail ¶ added in v0.19.0
func (rtb *RecorderTB) Fail()
func (*RecorderTB) FailNow ¶ added in v0.19.0
func (rtb *RecorderTB) FailNow()
func (*RecorderTB) Failed ¶ added in v0.19.0
func (rtb *RecorderTB) Failed() bool
func (*RecorderTB) Fatal ¶ added in v0.19.0
func (rtb *RecorderTB) Fatal(args ...interface{})
func (*RecorderTB) Fatalf ¶ added in v0.19.0
func (rtb *RecorderTB) Fatalf(format string, args ...interface{})
func (*RecorderTB) Forward ¶ added in v0.23.1
func (rtb *RecorderTB) Forward()
func (*RecorderTB) Helper ¶ added in v0.19.0
func (rtb *RecorderTB) Helper()
func (*RecorderTB) Log ¶ added in v0.19.0
func (rtb *RecorderTB) Log(args ...interface{})
func (*RecorderTB) Logf ¶ added in v0.19.0
func (rtb *RecorderTB) Logf(format string, args ...interface{})
type StubTB ¶
type StubTB struct { // TB is only present here to implement testing.TB interface's // unexported functions by embedding the interface itself. testing.TB IsFailed bool IsSkipped bool Logs []string StubName string StubTempDir string StubFailNow func() StubCleanup func(f func()) // contains filtered or unexported fields }
type Teardown ¶ added in v0.38.0
type Teardown struct { CallerOffset int // contains filtered or unexported fields }
func (*Teardown) Defer ¶ added in v0.38.0
func (td *Teardown) Defer(fn interface{}, args ...interface{})
Defer function defers the execution of a function until the current test case returns. Deferred functions are guaranteed to run, regardless of panics during the test case execution. Deferred function calls are pushed onto a testcase runtime stack. When an function passed to the Defer function, it will be executed as a deferred call in last-in-first-orderingOutput order.
It is advised to use this inside a testcase.Spec#Let memorization function when spec variable defined that has finalizer requirements. This allow the specification to ensure the object finalizer requirements to be met, without using an testcase.Spec#After where the memorized function would be executed always, regardless of its actual need.
In a practical example, this means that if you have common vars defined with testcase.Spec#Let memorization, which needs to be Closed for example, after the test case already run. Ensuring such objects Close call in an after block would cause an initialization of the memorized object list the time, even in tests where this is not needed.
e.g.:
- mock initialization with mock controller, where the mock controller #Finish function must be executed after each testCase suite.
- sql.DB / sql.Tx
- basically anything that has the io.Closer interface