go1.20.5
GoThrough

testing.TB

// TB is the interface common to T, B, and F. type TB interface { Cleanup(func()) Error(args ...any) Errorf(format string, args ...any) Fail() FailNow() Failed() bool Fatal(args ...any) Fatalf(format string, args ...any) Helper() Log(args ...any) Logf(format string, args ...any) Name() string Setenv(key string, value string) Skip(args ...any) SkipNow() Skipf(format string, args ...any) Skipped() bool TempDir() string }

testing.AllocsPerRun

// AllocsPerRun returns the average number of allocations during calls to f. // Although the return value has type float64, it will always be an integral value. // // To compute the number of allocations, the function will first be run once as // a warm-up. The average number of allocations over the specified number of // runs will then be measured and returned. // // AllocsPerRun sets GOMAXPROCS to 1 during its measurement and will restore // it before returning. func AllocsPerRun(runs int, f func()) (avg float64)

testing.Benchmark

// Benchmark benchmarks a single function. It is useful for creating // custom benchmarks that do not use the "go test" command. // // If f depends on testing flags, then Init must be used to register // those flags before calling Benchmark and before calling flag.Parse. // // If f calls Run, the result will be an estimate of running all its // subbenchmarks that don't call Run in sequence in a single benchmark. func Benchmark(f func(b *B)) BenchmarkResult

testing.CoverMode

// CoverMode reports what the test coverage mode is set to. The // values are "set", "count", or "atomic". The return value will be // empty if test coverage is not enabled. func CoverMode() string

testing.Coverage

// Coverage reports the current code coverage as a fraction in the range [0, 1]. // If coverage is not enabled, Coverage returns 0. // // When running a large set of sequential test cases, checking Coverage after each one // can be useful for identifying which test cases exercise new code paths. // It is not a replacement for the reports generated by 'go test -cover' and // 'go tool cover'. func Coverage() float64

testing.Init

// Init registers testing flags. These flags are automatically registered by // the "go test" command before running test functions, so Init is only needed // when calling functions such as Benchmark without using "go test". // // Init has no effect if it was already called. func Init()

testing.Main

// Main is an internal function, part of the implementation of the "go test" command. // It was exported because it is cross-package and predates "internal" packages. // It is no longer used by "go test" but preserved, as much as possible, for other // systems that simulate "go test" using Main, but Main sometimes cannot be updated as // new functionality is added to the testing package. // Systems simulating "go test" should be updated to use MainStart. func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample)

testing.MainStart

// MainStart is meant for use by tests generated by 'go test'. // It is not meant to be called directly and is not subject to the Go 1 compatibility document. // It may change signature from release to release. func MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, fuzzTargets []InternalFuzzTarget, examples []InternalExample) *M

testing.RegisterCover

// RegisterCover records the coverage data accumulators for the tests. // NOTE: This function is internal to the testing infrastructure and may change. // It is not covered (yet) by the Go 1 compatibility guidelines. func RegisterCover(c Cover)

testing.RunBenchmarks

// RunBenchmarks is an internal function but exported because it is cross-package; // it is part of the implementation of the "go test" command. func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark)

testing.RunExamples

// RunExamples is an internal function but exported because it is cross-package; // it is part of the implementation of the "go test" command. func RunExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ok bool)

testing.RunTests

// RunTests is an internal function but exported because it is cross-package; // it is part of the implementation of the "go test" command. func RunTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ok bool)

testing.Short

// Short reports whether the -test.short flag is set. func Short() bool

testing.Verbose

// Verbose reports whether the -test.v flag is set. func Verbose() bool