samber/cc-skills-golang / skills/golang-testing
golang-testing
VerifiedProduction-ready Golang tests — table-driven tests, testify suites and mocks, parallel tests, fuzzing, fixtures, goroutine leak detection with goleak, snapshot testing, code coverage, integration tests, idiomatic test naming. Use when writing or reviewing Go tests, choosing a testing approach, setting up Go test CI, or debugging flaky/slow tests. For testify-specific APIs see `samber/cc-skills-golang@golang-stretchr-testify`; for measurement methodology see `samber/cc-skills-golang@golang-benchmark`.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 17.5 KB |
| evals/evals.json | config | 21.5 KB |
| references/benchmarks.md | markdown | 1.9 KB |
| references/coverage.md | markdown | 1.8 KB |
| references/examples.md | markdown | 1.9 KB |
| references/helpers.md | markdown | 1.0 KB |
| references/http-testing.md | markdown | 2.2 KB |
| references/integration-testing.md | markdown | 4.4 KB |
| references/mocking.md | markdown | 4.6 KB |
references/coverage.md
View on GitHub# Code Coverage
Coverage measures which lines ran, not whether their behavior was asserted. Treat it as a gap finder — read the uncovered lines — not as a quality target to chase.
## Commands
```bash
# Generate coverage file
go test -coverprofile=coverage.out ./...
# View coverage in HTML (uncovered lines in red)
go tool cover -html=coverage.out
# Coverage by function
go tool cover -func=coverage.out
# Total coverage percentage
go tool cover -func=coverage.out | grep total
# Count how many times each statement ran, not just whether it ran
go test -covermode=count -coverprofile=coverage.out ./...
# Safe under -race (atomic counters)
go test -race -covermode=atomic -coverprofile=coverage.out ./...
# Attribute coverage of package A to tests living in package B
go test -coverpkg=./... ./...
# Coverage of a single package, printed inline
go test -cover ./internal/store
```
## Modes
| Mode | Records | Use when |
| --- | --- | --- |
| `set` | Statement executed (default) | Normal runs |
| `count` | Execution count per statement | Finding never-taken branches in hot paths |
| `atomic` | Count, race-safe | Any run combined with `-race` or `t.Parallel()` |
## Pitfalls
- **Per-package by default.** Without `-coverpkg`, a test in `api` exercising `store` reports nothing for `store`, making well-tested packages look untested.
- **Integration tests are invisible** unless the build tag is passed: `go test -tags=integration -coverprofile=...`.
- **Generated code inflates the number.** Exclude it before setting any threshold, otherwise the metric measures the generator.
- **A covered line is not an asserted line.** A test that calls a function and ignores its result reports 100% coverage and verifies nothing.
→ See `samber/cc-skills-golang@golang-continuous-integration` skill for wiring coverage reporting into CI.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |