MCPcopy Create free account
hub / github.com/RainbowMango/GoExpertProgramming / TestMain

Function TestMain

source/gotest/maintest_test.go:9–16  ·  view source on GitHub ↗

TestMain 用于主动执行各种测试,可以测试前后做setup和tear-down操作

(m *testing.M)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected