testinit

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fatal

func Fatal(v ...interface{})

Fatal works like log.Fatal but it ensure teardown functions will be called before exit.

func Main

func Main(m *testing.M)

Main should be called from TestMain to ensure Setup and Teardown functions will be called.

func TestMain(m *testing.M) { testinit.Main(m) }

func Setup

func Setup(idx int, f func())

Setup let you run test init() functions in defined order.

func init() { testinit.Setup(1, setup) }
func setup() { ... }

func Teardown

func Teardown(f func())

Teardown ensure f will be called before exiting from test. You should always call Main from TestMain and call Fatal instead of log.Fatal or os.Exit.

If Teardown will be called multiple times then f will be executed in reverse order - just like defer does.

Types

This section is empty.

Jump to

Keyboard shortcuts

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