_test.go file
A Go source file whose name ends in _test.go, which holds tests and is compiled only by go test, never into your binary.
In more detail
Put it next to the code it tests, in the same package. go test gathers every such file in the package into a temporary test binary.
Example
check_test.goRelated terms
- go test — The go subcommand that builds a test binary from the _test.go files in a package, runs every test function and reports what failed.
- Go testing package — Go's standard library package for writing tests, run by the go test command.
- test function — A Go function whose name starts with Test and which takes a *testing.T, so go test finds and runs it automatically.
Taught in
- The Standard testing Package — Concurrent Systems Programming with Go