What problem does it solve?
Go testing can be verbose and error-prone; this guide consolidates patterns from Google and Uber to help you write clear, maintainable Go tests that diagnose failures without digging into test sources.
Core Features & Use Cases
- Table-driven tests and subtests for comprehensive coverage and organized test structure.
- Parallel tests and proper setup/teardown with t.Helper and t.Cleanup to speed up feedback loops.
- No assertion libraries: prefer standard assertions and diffs (e.g., cmp.Diff) for reliable failure messages.
- Error semantics: use errors.Is and semantic checks to ensure robust failure handling.
- Test helpers: guidelines for creating helpers with t.Helper() and clean, reusable patterns.
Quick Start
Start by adopting table-driven tests with t.Run subtests and semantic comparisons using cmp.Diff for clear, diagnosable failures.