How NOT to Write a Test in Go
summary
Covers concrete anti-patterns and fixes: replaces duplicated checks with table-driven tests, demonstrates the t.Parallel loop-variable bug and its fix (copy loop var), recommends t.Cleanup over defer for test teardown, shows enabling the race detector with go test -race, mentions testify suites for complex setup, uses go test flags (shuffle seed, benchmem, -count) and gives a minimal GitHub Actions YAML to run go build and go test on push.
AI-written summary · about
chapters (10)
- 0:00Testing in Go
- 2:30Why test Go code
- 7:32Avoid test writing mistakes
- 12:11Table-driven tests
- 18:12Detecting data races
- 20:22Mocking in Go
- 24:35Random test order
- 26:01Writing benchmarks
- 30:15GitHub Actions tests
- 31:41Key takeaways








