← ClaudeAtlas

go-testslisted

Go testing conventions that follow established industry standards: the Go wiki's Test Comments, the test sections of the Google Go Style Guide, and the testing package. Covers where tests live, naming, useful failure messages (got before want, function and input named), cmp diffs, t.Error vs t.Fatal, table-driven tests and subtests, test helpers, fakes and real transports, examples, benchmarks, fuzz tests, and what to avoid (assertion libraries, sleeps, shared global state). TRIGGER when: writing, editing, or reviewing Go test code (_test.go files). DO NOT TRIGGER when: working in a non-Go language, or only on production code.
contrastiskey/eetc-claude-code · ★ 0 · Code & Development · score 62
Install: claude install-skill contrastiskey/eetc-claude-code
# Go Test Conventions Sources: [Go Test Comments](https://go.dev/wiki/TestComments), the test sections of the Google Go Style Guide ([decisions](https://google.github.io/styleguide/go/decisions#useful-test-failures), [best practices](https://google.github.io/styleguide/go/best-practices#tests)), and the [`testing`](https://pkg.go.dev/testing) package. General Go style (naming, errors, docs) lives in `eetc:go-code-style`. Project-specific test commands, fixtures and fakes live in the repo's CLAUDE.md or `codebase-overview` skill. ## Where tests live | Kind | File | Package | |------|------|---------| | Unit | `foo_test.go` next to `foo.go` | `package foo`: can reach unexported names | | Black box | `foo_test.go` next to `foo.go` | `package foo_test`: only the public API; also breaks import cycles | | Example | `example_test.go` | `package foo_test`, so examples show the `foo.` qualifier users write | | Fixtures | `testdata/` | ignored by the go tool | - Test doubles that other packages' tests need go in a `footest` package next to `foo` (`creditcardtest.Stub`), never in `foo` itself. - Tests that need real infrastructure skip under `-short` (`if testing.Short() { t.Skip("needs postgres") }`), or use the build tag the repo already has. ## Running | Command | What it runs | |---------|-------------| | `go test ./...` | Every package in the module | | `go test ./internal/orders` | One package | | `go test -run 'TestParse$' ./parser` | Tests matching the regexp | | `g