11.1 The go test Tool
The go test subcommand is a test driver for Go packages that are organized
according to certain conventions. In a package directory, files whose
names end with _test.go are not part of the package ordinarily built
by go build but are a part of it when built by go test.
Within *_test.go files, three kinds of functions are treated
specially: tests, benchmarks, and examples. A test function, which is a
function whose name begins with Test, exercises some program logic
for correct behavior; go test calls the test function and reports
the result, which is either
PASS or FAIL. A benchmark function has a name beginning with Benchmark and
measures the performance of some operation; go test reports the mean execution time ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access