Go Testing By Example
summary
Practical, concrete testing techniques for Go: 20 specific tips including table‑driven tests, using go test -coverprofile plus the uncover tool to find unexecuted lines, and writing exhaustive tests for all inputs up to size 10 backed by a slow reference implementation. Fixes include guarding against i+j overflow and proving it with a memory‑cheap test using a huge slice of empty strings. Use file‑based tests, a simple archive format Texar, updatable golden files (‑update flag), script‑based command tests, and CI deploy gating for go.dev.
AI-written summary · about
chapters (20)
- 0:00Why write tests
- 3:55Software engineering tests
- 6:02Make tests easy to add
- 7:27Use test coverage
- 9:14Coverage vs thought
- 10:59Write exhaustive tests
- 13:54Separate test cases
- 14:15Look for special cases
- 15:18Always add a test
- 17:06Test data in tables
- 19:35Test cases in files
- 20:18Compare implementations
- 22:25Make failures readable
- 24:11Update test answers
- 24:54Texar for multifile tests
- 28:51Annotate existing formats
- 30:16Write custom parsers
- 32:45High-quality Go tests
- 34:10Scripts as test cases
- 37:17Aim for continuous deployment








