Testing and quality
Unit, table, integration, benchmark, fuzz, race, and HTTP testing practices.
Testing in Go: Table Tests, HTTP, Fakes, and Coverage
Write effective Go tests with table-driven cases, subtests, httptest, fakes, race detection, benchmarks, and useful coverage.
Read tutorial Lesson 2 · Tutorial · Go 1.21+Writing Unit Tests in Go: A Practical Guide
Write golang unit tests that catch bugs: test structure, error checks, table cases, fakes, injected clocks, and coverage, with real go test output.
Read tutorial Lesson 3 · Tutorial · Go 1.22+Table-Driven Tests in Go: The Idiomatic Way
Golang table driven tests done right: subtests with t.Run, parallel cases, error tables with errors.Is, and golden files, with real tested output.
Read tutorial Lesson 4 · Tutorial · Go 1.24+ (b.Loop); the b.N form works on Go 1.7+Go Benchmarking: Measuring Performance with testing.B
Learn Go benchmarking with testing.B: read ns/op, B/op and allocs/op, avoid the dead-code trap, use b.Loop, and compare implementations you can trust.
Read tutorial Lesson 5 · Tutorial · Go 1.21+ (stdlib examples tested on Go 1.24.7)Mocking in Go: Test Doubles Without Magic
Learn golang mocking the idiomatic way: small interfaces plus hand-written fakes, spies, and httptest, with generated mocks only when they earn it.
Read tutorial Lesson 6 · Tutorial · Go 1.22+Integration Testing in Go: Testing Real Boundaries
Write Go integration tests that hit real boundaries: HTTP with httptest, a real Postgres, plus build tags and -short to keep go test ./... fast.
Read tutorial