Created
December 19, 2014 12:38
-
-
Save atotto/88ed1be361976807c171 to your computer and use it in GitHub Desktop.
go1.4 TestMain example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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