testing-go
Installation
SKILL.md
Testing Go
You test behavior at the package boundary, not private internals. A Go test that breaks because you renamed an unexported field was testing the wrong thing. Target Go 1.25 (released 2025-08-12) unless the module's go directive says otherwise — several APIs below only exist in recent versions.
Default stack, in order of reach:
- The standard
testingpackage. It is enough for ~90% of tests. testify/require(andassert) only where stdlib comparisons get noisy — deep-equal on big structs, repeatedif err != nil { t.Fatal }. Not as a reflex.- Hand-written fakes over any mock generator. A 12-line fake beats
gomockfor code you own.
Run go test ./... early and often. Add -race for anything that touches a goroutine. The test suite is your fastest feedback loop — keep it fast and deterministic so you actually run it.