Documentation ¶
Index ¶
- type RuntimeT
- func (t *RuntimeT) Cleanup(f func())
- func (t *RuntimeT) Error(args ...interface{})
- func (t *RuntimeT) Errorf(format string, args ...interface{})
- func (t *RuntimeT) Fail()
- func (t *RuntimeT) FailNow()
- func (t *RuntimeT) Failed() bool
- func (t *RuntimeT) Fatal(args ...interface{})
- func (t *RuntimeT) Fatalf(format string, args ...interface{})
- func (t *RuntimeT) Helper()
- func (t *RuntimeT) Log(args ...interface{})
- func (t *RuntimeT) Logf(format string, args ...interface{})
- func (t *RuntimeT) Name() string
- func (t *RuntimeT) Parallel()
- func (t *RuntimeT) Setenv(key string, value string)
- func (t *RuntimeT) Skip(args ...interface{})
- func (t *RuntimeT) SkipNow()
- func (t *RuntimeT) Skipf(format string, args ...interface{})
- func (t *RuntimeT) Skipped() bool
- func (t *RuntimeT) TempDir() string
- type T
- type TB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RuntimeT ¶
type RuntimeT struct {
// contains filtered or unexported fields
}
RuntimeT implements T and can be instantiated and run at runtime to mimic *testing.T behavior. Unlike *testing.T, this will simply panic for calls to Fatal. For calls to Error, you'll have to check the errors list to determine whether to exit yourself.
Parallel does not do anything.
func (*RuntimeT) Cleanup ¶ added in v1.14.0
func (t *RuntimeT) Cleanup(f func())
Cleanup registers a function to be called when the test and all its subtests complete. Cleanup functions will be called in last added, first called order.
This logic is copied from the standard go library
func (*RuntimeT) TempDir ¶
TempDir returns a temporary directory for the test to use. The directory is automatically removed by Cleanup when the test and all its subtests complete. Each subsequent call to t.TempDir returns a unique directory; if the directory creation fails, TempDir terminates the test by calling Fatal.
This logic is copied from the standard go library
type T ¶
type T interface { Cleanup(func()) Error(args ...interface{}) Errorf(format string, args ...interface{}) Fail() FailNow() Failed() bool Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) Helper() Log(args ...interface{}) Logf(format string, args ...interface{}) Name() string Parallel() Setenv(key string, value string) Skip(args ...interface{}) SkipNow() Skipf(format string, args ...interface{}) Skipped() bool TempDir() string }
T is the interface that mimics the standard library *testing.T.
In unit tests you can just pass a *testing.T struct. At runtime, outside of tests, you can pass in a RuntimeT struct from this package.
type TB ¶
type TB interface { Cleanup(func()) Error(args ...interface{}) Errorf(format string, args ...interface{}) Fail() FailNow() Failed() bool Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) Helper() Log(args ...interface{}) Logf(format string, args ...interface{}) Name() string Setenv(key string, value string) Skip(args ...interface{}) SkipNow() Skipf(format string, args ...interface{}) Skipped() bool TempDir() string }
TB is the interface common to T and B, copied from the standard library *testing.TB.
This interface should be used as the type of the testing argument to any test helper function that exists in the main codebase, which may be invoked by tests of type *testing.T and *testing.B.