comeonoliver/skillshub/go-testing
Claude Code and agent skill by comeonoliver/skillshub
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Use when writing, reviewing, or improving Go test code — including table-driven tests, subtests, parallel tests, test helpers, test doubles, and assertions with cmp.Diff. Also use when a user asks to write a test for a Go function, even if they don't mention specific patterns like table-driven tests or subtests. Does not cover benchmark performance testing (see go-performance).
Install
npx vskill@latest install comeonoliver/skillshub/go-testingSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as comeonoliver/skillshub/go-testing.
Go Testing
Quick Reference
| Pattern | Use When | |
|---|---|---|
t.Error | Default — report failure, keep running | |
t.Fatal | Setup failed or continuing is meaningless | |
cmp.Diff | Comparing structs, slices, maps, protos | |
| Table-driven | Many cases share identical logic | |
| Subtests | Need filtering, parallel execution, or naming | |
t.Helper() | Any test helper function (call as first statement) | |
t.Cleanup() | Teardown in helpers instead of defer |
Useful Test Failures
Normative: Test failures must be diagnosable without reading the testsource.
Every failure message must include: function name, inputs, actual (got), and expected (want). Use the format YourFunc(%v) = %v, want %v.
Always print got before want: got %v, want %v — never reversed.
No Assertion Libraries
Normative: Do not use assertion libraries. Usecmp.Difffor complexcomparisons.
For protocol buffers, add protocmp.Transform() as a cmp option. Always include the direction key (-want +got) in diff messages. Avoid comparing JSON/serialized output — compare semantically instead.
Read references/TEST-HELPERS.md when writingcustom comparison helpers or domain-specific test utilities.
t.Error vs t.Fatal
Normative: Uset.Errorby default to report all failures in one run.Uset.Fatalonly when continuing is impossible.
Choose `t.Fatal` when:
- Setup fails (DB connection, file load)
- The next assertion depends on the previous one succeeding (e.g., decode after
encode)
Never call `t.Fatal`/`t.FailNow` from a goroutine other than the test goroutine — use t.Error instead.
Read references/TEST-HELPERS.md when writinghelpers that need to choose between t.Error and t.Fatal, or for detailedexamples of both.
Table-Driven Tests
Seeassets/table-test-template.gowhen scaffolding a new table-driven test and need the canonical struct, loop, and subtest layout.
Advisory: Use table-driven tests when many cases share identical logic.
Use table tests when: all cases run the same code path with no conditional setup, mocking, or assertions. A single shouldErr bool is acceptable.
Don't use table tests when: cases need complex setup, conditional mocking, or multiple branches — write separate test functions instead.
Key rules:
- Use field names when cases span many lines or have same-type adjacent fields
- Include inputs in failure messages — never identify rows by index
when writing table-driven tests, subtests, or parallel tests.
Validation: After generating or modifying tests, rungo test -run TestXxx -vto verify the tests compile and pass. Fix any compilation errors before proceeding.
Test Helpers
Normative: Test helpers must callt.Helper()first and uset.Cleanup()for teardown.
Read references/TEST-HELPERS.md when writingtest helpers, cleanup functions, or custom comparison utilities.
Test Error Semantics
Advisory: Test error semantics, not error message strings.
For simple presence checks when specific semantics don't matter:
Test Organization
Read references/TEST-ORGANIZATION.md whenworking with test doubles, choosing test package placement, or scoping testsetup.
Read references/VALIDATION-APIS.md whendesigning reusable test validation functions.
Integration Testing
Read references/INTEGRATION.md when writingTestMain, acceptance tests, or tests that need real HTTP/RPC transports.
Available Scripts
- `scripts/gen-table-test.sh` — Generates a table-driven test scaffold
Related Skills
- Error testing: See go-error-handling when testing error semantics with
errors.Is/errors.Asor sentinel errors - Interface mocking: See go-interfaces when creating test doubles by implementing interfaces at the consumer side
- Naming test functions: See go-naming when naming test functions, subtests, or test helper utilities
- Linter integration: See go-linting when running linters alongside tests in CI or pre-commit hooks
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cxuu/golang-skills/go-testing/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/comeonoliver/skillshub/go-testing)