testmain

package
v1.21.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: BSD-2-Clause Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExampleFunc

type ExampleFunc struct {
	Location    FuncLocation // Where the function is defined.
	Name        string       // Function name.
	Output      string       // Expected output.
	Unordered   bool         // Output is allowed to be unordered.
	EmptyOutput bool         // Whether the output is expected to be empty.
}

ExampleFunc describes an example.

func (ExampleFunc) Executable

func (ef ExampleFunc) Executable() bool

Executable returns true if the example function should be executed with tests.

type FuncLocation

type FuncLocation uint8

FuncLocation describes whether a test function is in-package or external (i.e. in the xxx_test package).

const (
	// LocUnknown is the default, invalid value of the PkgType.
	LocUnknown FuncLocation = iota
	// LocInPackage is an in-package test.
	LocInPackage
	// LocExternal is an external test (i.e. in the xxx_test package).
	LocExternal
)

func (FuncLocation) String

func (tl FuncLocation) String() string

type TestFunc

type TestFunc struct {
	Location FuncLocation // Where the function is defined.
	Name     string       // Function name.
}

TestFunc describes a single test/benchmark/fuzz function in a package.

type TestMain

type TestMain struct {
	Package    *build.Package
	Context    *build.Context
	Tests      []TestFunc
	Benchmarks []TestFunc
	Fuzz       []TestFunc
	Examples   []ExampleFunc
	TestMain   *TestFunc
}

TestMain is a helper type responsible for generation of the test main package.

func (*TestMain) ExecutesTest

func (tm *TestMain) ExecutesTest() bool

ExecutesTest returns true if in-package test package has executable tests.

func (*TestMain) ExecutesXTest

func (tm *TestMain) ExecutesXTest() bool

ExecutesXTest returns true if external package test package has executable tests.

func (*TestMain) ImportTest

func (tm *TestMain) ImportTest() bool

ImportTest returns true if in-package test package needs to be imported.

func (*TestMain) ImportXTest

func (tm *TestMain) ImportXTest() bool

ImportXTest returns true if external test package needs to be imported.

func (*TestMain) Scan

func (tm *TestMain) Scan(fset *token.FileSet) error

Scan package for tests functions.

func (*TestMain) Synthesize

func (tm *TestMain) Synthesize(fset *token.FileSet) (*build.Package, *ast.File, error)

Synthesize main package for the tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL