go1.4 TestMain example
package example_test | |
import ( | |
"os" | |
"testing" | |
) | |
func TestA(t *testing.T) { | |
} | |
func TestB(t *testing.T) { | |
} | |
func setup() { | |
println("setup") | |
} | |
func teardown() { | |
println("teardown") | |
} | |
func TestMain(m *testing.M) { | |
setup() | |
ret := m.Run() | |
if ret == 0 { | |
teardown() | |
} | |
os.Exit(ret) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment