Open mikedonnici opened 6 years ago
At the moment have this:
func TestMain(m *testing.M) {
err := data.SetupMySQL()
if err != nil {
log.Fatalln(err)
}
defer data.TearDownMySQL()
err = data.SetupMongoDB()
if err != nil {
log.Fatalln(err)
}
defer data.TearDownMongoDB()
m.Run()
}
Will change to this:
func TestMember(t *testing.T) {
err := data.SetupMySQL()
if err != nil {
log.Fatalln(err)
}
defer data.TearDownMySQL()
err = data.SetupMongoDB()
if err != nil {
log.Fatalln(err)
}
defer data.TearDownMongoDB()
t.Run("member", func(t *testing.T) {
t.Run("testPingDatabase", testPingDatabase)
t.Run("testByID", testByID)
// all test func with lowe case 'T'
})
}
Use test groups rather than m.Run()