writing-go-tests
Installation
SKILL.md
Go Testing Best Practices
This skill provides actionable testing guidelines. For detailed implementation patterns, code examples, rationale, and production system references, consult go-testing-best-practices.md.
When Working with Go Tests
Always apply these current best practices:
1. Test Organisation
- Place test files alongside source code using
*_test.gonaming - Use internal tests (same package) for unit testing unexported functions
- Use external tests (
package foo_test) for integration testing and examples - Split test files by functionality when they exceed 500-800 lines (e.g.,
handler_auth_test.go,handler_validation_test.go)
2. Table-Driven Testing
- Prefer map-based tables over slice-based for automatic unique test names
- Use descriptive test case names that appear in failure output
- See detailed guide for complete pattern and examples