
Golang Testing
Write, review, and stabilize Go tests with idiomatic table-driven suites, mocks, fuzzing, and CI-ready patterns instead of guessing frameworks.
Overview
Golang-testing is an agent skill most often used in Ship (also Build backend) that guides production-ready Go tests—table-driven cases, testify, fuzzing, goleak, and CI setup.
Install
npx skills add https://github.com/samber/cc-skills-golang --skill golang-testingWhat is this skill?
- Table-driven tests, testify suites/mocks, parallel tests, fuzzing, fixtures, and snapshot testing
- Goroutine leak detection with goleak and guidance for integration vs unit boundaries
- Idiomatic test naming plus flaky/slow test debugging and CI setup for Go
- Write mode and review-oriented workflows with ultrathink for strategy and failure analysis
- Cross-links to golang-stretchr-testify and golang-benchmark for specialized APIs and measurement
- Write mode and review-oriented modes for test generation and failure analysis
- Covers table-driven tests, fuzzing, goleak, snapshot testing, and integration tests in one skill
Adoption & trust: 4k installs on skills.sh; 2k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are shipping Go code but tests are ad hoc, flaky, or missing the idioms that keep behavior specified and CI trustworthy.
Who is it for?
Indie Go services, CLIs, or APIs where you want one agent pass to design tests, fix flakiness, and wire basic CI expectations.
Skip if: Teams that only need raw testify cookbook snippets without strategy (use golang-stretchr-testify) or non-Go stacks.
When should I use this skill?
Writing or reviewing Go tests, choosing a testing approach, setting up Go test CI, or debugging flaky/slow tests.
What do I get? / Deliverables
You get structured Go test plans and implementations with naming, parallelism, mocks, and leak checks aligned to your package—then use golang-benchmark or golang-stretchr-testify when you need measurement or testify-spec
- New or updated `_test.go` files
- Test strategy notes (table-driven layout, mocks, integration scope)
- CI-oriented test commands and lint hooks
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Shipping safely depends on executable specs; this skill is shelved under Ship → Testing because its triggers center on test authoring, review, flaky-test debugging, and Go test CI. Subphase testing matches writing/reviewing tests, parallelization, coverage, integration tests, and goleak-style reliability checks.
Where it fits
Scaffold table-driven tests and mocks while implementing a new HTTP handler.
Run a review pass on existing tests for parallelism misuse and missing edge cases.
Treat failing CI test logs as input to failure analysis before merge.
Add integration tests and goleak checks after goroutine leaks appear under load.
How it compares
Use instead of generic "write some unit tests" prompts when you want Go-specific patterns (table-driven, goleak, fuzz) in one workflow skill.
Common Questions / FAQ
Who is golang-testing for?
Solo and indie builders shipping Go backends, CLIs, or APIs with Claude Code, Cursor, or similar agents who want tests that constrain behavior, not vanity coverage.
When should I use golang-testing?
During Build when adding features that need specs; in Ship when reviewing `_test.go`, setting up Go test CI, or debugging slow/flaky tests; and before release when integration or leak issues show up in production-like runs.
Is golang-testing safe to install?
It expects local `go`, `gotests`, and optional golangci-lint with shell/git/file access—review the Security Audits panel on this page and scope agent permissions to your repo.
Workflow Chain
Then invoke: golang stretchr testify, golang benchmark
SKILL.md
READMESKILL.md - Golang Testing
**Persona:** You are a Go engineer who treats tests as executable specifications. You write tests to constrain behavior, not to hit coverage targets. **Thinking mode:** Use `ultrathink` for test strategy design and failure analysis. Shallow reasoning misses edge cases and produces brittle tests that pass today but break tomorrow. **Modes:** - **Write mode** — generating new tests for existing or new code. Work sequentially through the code under test; use `gotests` to scaffold table-driven tests, then enrich with edge cases and error paths. - **Review mode** — reviewing a PR's test changes. Focus on the diff: check coverage of new behaviour, assertion quality, table-driven structure, and absence of flakiness patterns. Sequential. - **Audit mode** — auditing an existing test suite for gaps, flakiness, or bad patterns (order-dependent tests, missing `t.Parallel()`, implementation-detail coupling). Launch up to 3 parallel sub-agents split by concern: (1) unit test quality and coverage gaps, (2) integration test isolation and build tags, (3) goroutine leaks and race conditions. - **Debug mode** — a test is failing or flaky. Work sequentially: reproduce reliably, isolate the failing assertion, trace the root cause in production code or test setup. > **Community default.** A company skill that explicitly supersedes `samber/cc-skills-golang@golang-testing` skill takes precedence. # Go Testing Best Practices This skill guides the creation of production-ready tests for Go applications. Follow these principles to write maintainable, fast, and reliable tests. ## Best Practices Summary 1. Table-driven tests MUST use named subtests -- every test case needs a `name` field passed to `t.Run` 2. Integration tests MUST use build tags (`//go:build integration`) to separate from unit tests 3. Tests MUST NOT depend on execution order -- each test MUST be independently runnable 4. Independent tests SHOULD use `t.Parallel()` when possible 5. NEVER test implementation details -- test observable behavior and public API contracts 6. Packages with goroutines SHOULD use `goleak.VerifyTestMain` in `TestMain` to detect goroutine leaks 7. Use testify as helpers, not a replacement for standard library 8. Mock interfaces, not concrete types 9. Keep unit tests fast (< 1ms), use build tags for integration tests 10. Run tests with race detection in CI 11. Include examples as executable documentation ## Test Structure and Organization ### File Conventions ```go // package_test.go - tests in same package (white-box, access unexported) package mypackage // mypackage_test.go - tests in test package (black-box, public API only) package mypackage_test ``` ### Naming Conventions ```go func TestAdd(t *testing.T) { ... } // function test func TestMyStruct_MyMethod(t *testing.T) { ... } // method test func BenchmarkAdd(b *testing.B) { ... } // benc