LESSON · 1 OF 23

Testing is built into Go

Testing is built into Go

Testing is part of the toolchain. There is no separate framework to install, no runner to configure, no assertion library to pick. The standard library ships a testing package, and the go command ships a go test subcommand. Together they cover writing tests, running them, measuring coverage, and filtering by name.

That means a fresh Go install can already test code. You write a test function, save the file, and run go test. Nothing else is required.

Most Go projects, including the standard library itself, lean on this built-in tooling for the vast majority of their tests and never reach for a third-party framework.

The rest of this topic walks through the pieces one at a time: where test files live, the shape of a test function, how you report a failure, and the flags you run tests with.

Spin up a fresh environment and practice live.
go · fresh machine · ready in under a minute