package testing

Import Path
	testing (on golang.org and go.dev)

Dependency Relation
	imports 19 packages, and imported by 2 packages

Involved Source Files
	    allocs.go
	    benchmark.go
	    cover.go
	    example.go
	    match.go
	    run_example.go
	d-> testing.go

Exported Type Names

type B (struct) B is a type passed to Benchmark functions to manage benchmark timing and to specify the number of iterations to run. A benchmark ends when its Benchmark function returns or calls any of the methods FailNow, Fatal, Fatalf, SkipNow, Skip, or Skipf. Those methods must be called only from the goroutine running the Benchmark function. The other reporting methods, such as the variations of Log and Error, may be called simultaneously from multiple goroutines. Like in tests, benchmark logs are accumulated during execution and dumped to standard output when done. Unlike in tests, benchmark logs are always printed, so as not to hide output whose existence may be affecting benchmark results. N int (*T) Cleanup(f func()) (*T) Error(args ...interface{}) (*T) Errorf(format string, args ...interface{}) (*T) Fail() (*T) FailNow() (*T) Failed() bool (*T) Fatal(args ...interface{}) (*T) Fatalf(format string, args ...interface{}) (*T) Helper() (*T) Log(args ...interface{}) (*T) Logf(format string, args ...interface{}) (*T) Name() string (*T) ReportAllocs() (*T) ReportMetric(n float64, unit string) (*T) ResetTimer() (*T) Run(name string, f func(b *B)) bool (*T) RunParallel(body func(*PB)) (*T) SetBytes(n int64) (*T) SetParallelism(p int) (*T) Skip(args ...interface{}) (*T) SkipNow() (*T) Skipf(format string, args ...interface{}) (*T) Skipped() bool (*T) StartTimer() (*T) StopTimer() (*T) TempDir() string *T : TB
type BenchmarkResult (struct) BenchmarkResult contains the results of a benchmark run. Bytes int64 Extra map[string]float64 MemAllocs uint64 MemBytes uint64 N int T time.Duration (T) AllocedBytesPerOp() int64 (T) AllocsPerOp() int64 (T) MemString() string (T) NsPerOp() int64 (T) String() string T : expvar.Var T : fmt.Stringer func Benchmark(f func(b *B)) BenchmarkResult
type Cover (struct) Cover records information about test coverage checking. NOTE: This struct is internal to the testing infrastructure and may change. It is not covered (yet) by the Go 1 compatibility guidelines. Blocks map[string][]CoverBlock Counters map[string][]uint32 CoveredPackages string Mode string func RegisterCover(c Cover)
type CoverBlock (struct) CoverBlock records the coverage data for a single basic block. The fields are 1-indexed, as in an editor: The opening line of the file is number 1, for example. Columns are measured in bytes. NOTE: This struct is internal to the testing infrastructure and may change. It is not covered (yet) by the Go 1 compatibility guidelines. Col0 uint16 Col1 uint16 Line0 uint32 Line1 uint32 Stmts uint16
type InternalBenchmark (struct) InternalBenchmark is an internal type but exported because it is cross-package; it is part of the implementation of the "go test" command. F func(b *B) Name string func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) func MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark)
type InternalExample (struct) F func() Name string Output string Unordered bool func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) func MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M func RunExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ok bool)
type InternalTest (struct) InternalTest is an internal type but exported because it is cross-package; it is part of the implementation of the "go test" command. F func(*T) Name string func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) func MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M func RunTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ok bool)
type M (struct) M is a type passed to a TestMain function to run the actual tests. (*T) Run() (code int) func MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M
type PB (struct) A PB is used by RunParallel for running parallel benchmarks. (*T) Next() bool
type T (struct) T is a type passed to Test functions to manage test state and support formatted test logs. A test ends when its Test function returns or calls any of the methods FailNow, Fatal, Fatalf, SkipNow, Skip, or Skipf. Those methods, as well as the Parallel method, must be called only from the goroutine running the Test function. The other reporting methods, such as the variations of Log and Error, may be called simultaneously from multiple goroutines. (*T) Cleanup(f func()) (*T) Deadline() (deadline time.Time, ok bool) (*T) Error(args ...interface{}) (*T) Errorf(format string, args ...interface{}) (*T) Fail() (*T) FailNow() (*T) Failed() bool (*T) Fatal(args ...interface{}) (*T) Fatalf(format string, args ...interface{}) (*T) Helper() (*T) Log(args ...interface{}) (*T) Logf(format string, args ...interface{}) (*T) Name() string (*T) Parallel() (*T) Run(name string, f func(t *T)) bool (*T) Skip(args ...interface{}) (*T) SkipNow() (*T) Skipf(format string, args ...interface{}) (*T) Skipped() bool (*T) TempDir() string *T : TB func vendor/golang.org/x/net/nettest.TestConn(t *T, mp nettest.MakePipe)
type TB (interface) TB is the interface common to T and B. (T) Cleanup(func()) (T) Error(args ...interface{}) (T) Errorf(format string, args ...interface{}) (T) Fail() (T) FailNow() (T) Failed() bool (T) Fatal(args ...interface{}) (T) Fatalf(format string, args ...interface{}) (T) Helper() (T) Log(args ...interface{}) (T) Logf(format string, args ...interface{}) (T) Name() string (T) Skip(args ...interface{}) (T) SkipNow() (T) Skipf(format string, args ...interface{}) (T) Skipped() bool (T) TempDir() string *B *T func internal/testenv.GoToolPath(t TB) string func internal/testenv.MustHaveCGO(t TB) func internal/testenv.MustHaveExec(t TB) func internal/testenv.MustHaveExecPath(t TB, path string) func internal/testenv.MustHaveExternalNetwork(t TB) func internal/testenv.MustHaveGoBuild(t TB) func internal/testenv.MustHaveGoRun(t TB) func internal/testenv.MustHaveLink(t TB) func internal/testenv.MustHaveSymlink(t TB) func internal/testenv.SkipFlaky(t TB, issue int) func internal/testenv.SkipFlakyNet(t TB)
Exported Values
func AllocsPerRun(runs int, f func()) (avg float64) 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 Benchmark(f func(b *B)) BenchmarkResult 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 Coverage() float64 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 CoverMode() string 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 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 Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) 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 MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M 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 RegisterCover(c Cover) 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 RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark) RunBenchmarks 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) RunExamples 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) RunTests is an internal function but exported because it is cross-package; it is part of the implementation of the "go test" command.
func Short() bool Short reports whether the -test.short flag is set.
func Verbose() bool Verbose reports whether the -test.v flag is set.