init_test.go 401 B

1234567891011121314151617181920212223242526
  1. package dao
  2. import (
  3. "flag"
  4. "os"
  5. "testing"
  6. "gitea.ckfah.com/cjjy/gocommon/pkg/boot"
  7. )
  8. /**
  9. 每个test 都会使用这个函数调用
  10. */
  11. func TestMain(m *testing.M) {
  12. // 解析参数记得
  13. flag.Parse()
  14. // 初始化资源,前置处理器
  15. boot.Init(boot.DB, boot.Trace)
  16. // 执行我们的test,其实就是个切面
  17. exitCode := m.Run()
  18. // 退出,后置处理器
  19. os.Exit(exitCode)
  20. }