testmain

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: BSD-2-Clause Imports: 16 Imported by: 0

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.PackageData
	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.PackageData, *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