You can use example below to prepare dependencies that test cases require in order to run as expected. You also have an option to destroy all dependencies after running the test cases. It is same as PHPUnit’s setUp
and tearDown
functionality.
// internal/league/testutility_test.go
package league
import (
"fmt"
"os"
"testing"
)
func TestMain(m *testing.M) {
setup()
code := m.Run()
teardown()
os.Exit(code)
}
#go #golang