Testing package
The testing package is Go’s standard-library package for defining, running, and reporting automated tests and benchmarks.
Go in Practice, Second Edition
The Go testing package is a standard-library package for defining and running automated tests and reporting test failures.
- How it is used
- Defines and runs automated package tests while reporting failures and measuring coverage.
- How deep it goes
- Demonstrates test-file naming, Test functions, failure output, package commands, and coverage, but not advanced test organization.
- Examples
- Uses a reverse-name function, TestName, Unicode input, failure diagnostics, rune conversion, and coverage output.
- What you can do after
- Diagnose/debug implementation defects with Test functions, go test output, assertions, and coverage reports.
Read how Go in Practice, Second Edition explains testing package →
Learn Go with Pocket-Sized Projects
The Go testing package provides support for automated tests, benchmarks, and related test execution features.
- How it is used
- Provides standard-library tools for writing, executing, and organizing Go tests, examples, and benchmarks.
- How deep it goes
- Explains test signatures, four execution phases, scenario naming, table-driven cases, and output checks without covering testing internals.
- Examples
- Demonstrates greet tests for English, French, and unknown languages, using expected values, actual values, and t.Errorf.
- What you can do after
- Apply the testing package to write scenario tests, report failures, run go test, and structure multi-input checks.
Read how Learn Go with Pocket-Sized Projects explains testing package →
Related concepts
- go testused by · go test is the Go command that builds and runs tests for specified packages and can also execute benchmarks and report coverage.
- testing.T.Runused by · testing.T.Run is a Go testing method that creates and executes a named subtest and reports its result to the parent test.
- Terratestused by · Terratest is a Go library for testing infrastructure code and infrastructure deployments.
- example testuses · An example test is a Go test function whose output both documents API behavior and serves as an executable check.
- standard librarypart of · A standard library is a collection of reusable modules, types, functions, APIs, and other facilities distributed with a programming language implementation or platform.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

