Testing - Golang - Complete Documentation by ntxm.org

Go Testing Basics

Write tests with the testing package and run them with go test, including running a single test and verbose output.

Organizing Go Tests

Write table-driven tests, name each case with t.Run subtests, and keep tests short with helpers and t.Cleanup.

Testing Go Code with Dependencies

Replace databases, email and the clock with fakes through small interfaces, and test HTTP handlers and clients with httptest.

Benchmarks, Fuzzing and Coverage in Go

Measure speed with benchmarks, find edge cases with fuzzing, and see untested code with coverage reports.