| name | test-review |
| description | Test quality checklist, security testing requirements, dynamic analysis, and test organization conventions for Go applications. Load when conducting test reviews. |
| compatibility | ["claude-code","opencode","github-copilot"] |
| metadata | {"version":"1.0","author":"team"} |
Testing Pyramid
| Level | Proportion | Scope | Speed |
|---|
| Unit tests | 80% | Single functions in isolation | Fast (<100ms) |
| Module tests | 15% | Package-level behavior | Medium (<1s) |
| Integration tests | 5% | System boundaries | Slow (>1s) |
Test Quality Checklist
Test Coverage
Table-Driven Tests
Useful Failure Messages
Test Helpers
Mocking Policy
- Prefer real implementations with test data
- Mock only at system boundaries (HTTP, WebSocket, filesystem)
- Never mock internal packages
- Hand-write simple mocks; avoid mock frameworks
| Mock Type | Acceptable | Location |
|---|
| HTTP client | Yes | System boundary |
| Internal types | No | Use real implementation |
| Time/Clock | Yes | Deterministic testing |
Security Testing Requirements
Boundary Testing
Error Path Testing
Concurrency Testing
Input Validation Testing
Dynamic Analysis
Go Race Detector
go test -race ./...
Detects data races at runtime. Should run on all tests in CI.
Vet and Static Analysis
go vet ./...
Catches common mistakes. Should block merge on failure.
Fuzz Testing (Go 1.18+)
For input parsing code, verify fuzz tests exist:
func FuzzParseInput(f *testing.F) {
f.Add([]byte(`{"id":"test"}`))
f.Fuzz(func(t *testing.T, data []byte) {
ParseInput(data)
})
}
Fuzz test requirements:
Test Organization
File Naming
*_test.go in same package for unit tests
*_integration_test.go with build tag for integration tests
Build Tags for Integration Tests
package mypackage_test
Test Data
- Place fixtures in
testdata/ directory
- Use descriptive names:
valid_input.json, malformed_response.json
- Include edge case fixtures:
empty.json, null_fields.json
Common Issues to Flag
[AUTOFIX] Issues
- Missing
t.Helper() in helper functions
- Sleep-based synchronization (use channels)
- Hardcoded test values that should be in table
- Missing error case in table-driven test
[ESCALATE] Issues
- No concurrent access testing for shared state
- Missing integration test for external service
- Test coverage significantly below 80%
[CLARIFY:security-reviewer] Issues
- Test exposes sensitive data handling patterns
- Error message content needs security review