TestMain 用于主动执行各种测试,可以测试前后做setup和tear-down操作
(m *testing.M)
| 7 | |
| 8 | // TestMain 用于主动执行各种测试,可以测试前后做setup和tear-down操作 |
| 9 | func TestMain(m *testing.M) { |
| 10 | println("TestMain setup.") |
| 11 | |
| 12 | retCode := m.Run() // 执行测试,包括单元测试、性能测试和示例测试 |
| 13 | |
| 14 | println("TestMain tear-down.") |
| 15 | os.Exit(retCode) |
| 16 | } |
nothing calls this directly
no outgoing calls
no test coverage detected