Provide setup and teardow to your test with g0 1.4 testing module:
func setUp() {
...
}
func tearDown() {
...
}
func TestMain(m *testing.M) {
setUp()
r := m.Run()
tearDown() // cannot run tearDown in a defer because of os.Exit
os.Exit(r)
}
func TestFoo(t *testing.T) {
...
...
}
func TestBar(t *testing.T) {
...
...
}
No comments:
Post a Comment