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.

In more detail

go test finds functions named TestSomething that take a *testing.T and runs them. The three-dot pattern after a path means that package and every package below it, so go test ./... tests a whole module. A non-zero exit code on failure lets a pipeline stop a bad release.

Examples

go test ./...
go test -race ./...

Related terms

Taught in

References