golang-testing
Installation
SKILL.md
Go Testing
Build Workflow
- Inspect existing
_test.gofiles and match local assertion, fake, fixture, and package style. - Prefer standard
testingtools first: table tests, subtests,t.Helper,t.Cleanup,t.TempDir,httptest,iotest,fstest, benchmarks, and fuzz tests. - Add tests at the lowest useful boundary. Use integration tests only when behavior depends on external systems or wiring.
- Test public behavior, edge cases, error classification, cancellation/timeouts, and concurrency safety where relevant.
- Use fakes/stubs over broad mocks when interfaces are small. Avoid generating mocks for interfaces that do not exist yet.
- Run focused tests first, then
go test ./.... Use-racefor concurrency/shared-memory changes. - Keep tests deterministic: no real time sleeps without control, no network unless explicitly integration-gated, no order dependence.
Audit Workflow
- Inspect changed or target code and nearby
_test.gofiles before judging coverage. - Check whether tests cover public behavior, edge cases, error classification, cancellation/timeouts, concurrency safety, and integration boundaries.
- Flag brittle tests: sleeps, real network, order dependence, shared state, broad mocks, hidden fixtures, or over-testing internals.
- Recommend the smallest useful test additions and whether they should be unit, integration, fuzz, benchmark, or race checks.
- Pair with
golang-code-auditwhen producing a full findings-first review.