How to run golang tests sequentially?

前端 未结 4 1024
情歌与酒
情歌与酒 2020-12-03 11:10

When I run go test, my output:

--- FAIL: TestGETSearchSuccess (0.00s)
        Location:       drivers_api_test.go:283
        Error:          No         


        
4条回答
  •  自闭症患者
    2020-12-03 11:37

    The best way to achieve that is to create a TestMain, as presented here.

    import (
      "testing"
      "os"
    )
    
    func TestMain(m *testing.M) {
       // Do your stuff here
       os.Exit(m.Run())
    }
    

提交回复
热议问题