z-go-testing
Installation
SKILL.md
Go Testing
Assumes test depth is already decided — see [[z-testing-strategy]] for MVP vs regression mode and whether a change needs a BDD contract first.
Structure
// same package — white-box access, the common default
package mypackage
// test package — public API only, when isolating the exported surface
package mypackage_test
Naming: TestFoo, TestFoo_Method, BenchmarkFoo, ExampleFoo, FuzzFoo.
Table-driven tests
Always name cases; build the table incrementally in TDD — one case per cycle. Under a zapply red stage the plan's behavior contract is already closed — write the full contract table up front there. Loop-variable capture (tt := tt) is redundant for loop variables declared with := under Go 1.22+ language semantics; assignments with = still reuse variables. Check the owning module's version, not just the toolchain; see [[z-go-modernize]].