Skip to content

Instantly share code, notes, and snippets.

@atotto
Created December 19, 2014 12:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atotto/88ed1be361976807c171 to your computer and use it in GitHub Desktop.
Save atotto/88ed1be361976807c171 to your computer and use it in GitHub Desktop.
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