Documentation ¶
Index ¶
- Constants
- func RunTests(m *testing.M, opts ...PackageOptions)
- type PackageHook
- type PackageOptions
- func Setup(fn SetupFunc) PackageOptions
- func SetupWithOrder(order int, fn SetupFunc) PackageOptions
- func Teardown(fn TeardownFunc) PackageOptions
- func TeardownWithOrder(order int, fn TeardownFunc) PackageOptions
- func TestOptions(opts ...test.Options) PackageOptions
- func TestSetup(fn test.SetupFunc) PackageOptions
- func TestSetupWithOrder(order int, fn test.SetupFunc) PackageOptions
- func TestTeardown(fn test.TeardownFunc) PackageOptions
- func TestTeardownWithOrder(order int, fn test.TeardownFunc) PackageOptions
- func WithOptions(opts ...PackageOptions) PackageOptions
- type SetupFunc
- type TeardownFunc
Constants ¶
const (
HookOrderPackage int = -0xffff
)
Variables ¶
This section is empty.
Functions ¶
func RunTests ¶
func RunTests(m *testing.M, opts ...PackageOptions)
Types ¶
type PackageHook ¶
type PackageOptions ¶
type PackageOptions func(opt *pkg)
func Setup ¶
func Setup(fn SetupFunc) PackageOptions
Setup register the given setup function to run at order 0, higher(smaller) order runs first package setup runs once per test package, and should only be registered in TestMain(m *testing.M)
func SetupWithOrder ¶
func SetupWithOrder(order int, fn SetupFunc) PackageOptions
SetupWithOrder register the given setup function to run at given order, higher(smaller) order runs first package setup runs once per test package, and should only be registered in TestMain(m *testing.M)
func Teardown ¶
func Teardown(fn TeardownFunc) PackageOptions
Teardown register the given teardown function to run at order 0, higher(smaller) order runs LAST package teardown runs once per test package, and should only be registered in TestMain(m *testing.M)
func TeardownWithOrder ¶
func TeardownWithOrder(order int, fn TeardownFunc) PackageOptions
TeardownWithOrder register the given teardown function to run at given order, higher(smaller) order runs LAST package teardown runs once per test package, and should only be registered in TestMain(m *testing.M)
func TestOptions ¶
func TestOptions(opts ...test.Options) PackageOptions
TestOptions register per-test options at package level: only declared once in TestMain(m *testing.M) All test.Options are applied once per Test*()
func TestSetup ¶
func TestSetup(fn test.SetupFunc) PackageOptions
TestSetup is a convenient function equivalent to TestOptions(test.Setup(fn))
func TestSetupWithOrder ¶
func TestSetupWithOrder(order int, fn test.SetupFunc) PackageOptions
TestSetupWithOrder is a convenient function equivalent to TestOptions(test.Hooks(test.NewSetupHook(order, fn)))
func TestTeardown ¶
func TestTeardown(fn test.TeardownFunc) PackageOptions
TestTeardown is a convenient function equivalent to TestOptions(test.Teardown(fn))
func TestTeardownWithOrder ¶
func TestTeardownWithOrder(order int, fn test.TeardownFunc) PackageOptions
TestTeardownWithOrder is a convenient function equivalent to TestOptions(test.Hooks(test.NewTeardownHook(order, fn)))
func WithOptions ¶
func WithOptions(opts ...PackageOptions) PackageOptions
WithOptions group multiple PackageOptions into one, typically used for other test utilities to provide single entry point of certain feature. Not recommended for test implementers to use directly
type SetupFunc ¶
type SetupFunc func() error
SetupFunc is package level setup function that run once per package
type TeardownFunc ¶
type TeardownFunc func() error
TeardownFunc is package level teardown function that run once per package