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 →
Also covered in
- Shipping Go: Develop, deliver, discuss, design, and go again
- Go by Example
- Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu
What to know first
- GoGo is a statically typed, compiled, general-purpose programming language with garbage collection and built-in support for concurrency.
- software testingSoftware testing is the systematic evaluation of software under specified inputs or conditions to assess its behavior against expected results or requirements and identify defects.
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.
- 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.
- Terratestused by · Terratest is a Go library for testing infrastructure code and infrastructure deployments.
- 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.
Questions about testing package
What is testing package?
The testing package is Go’s standard-library package for defining, running, and reporting automated tests and benchmarks.
Which Manning books explain testing package?
Go in Practice, Second Edition and Learn Go with Pocket-Sized Projects.
What should I know before learning testing package?
Manning books that teach testing package usually introduce Go and software testing first.
What is testing package part of?
Testing package is part of standard library. 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.

