A friend had just started a consulting gig with a new team, so I asked him, “How are they doing?” He said, “They’re writing legacy code, man.” —Michael Feathers, “Working Effectively with Legacy Code”
The Power of Go: Tests is a compilation of all the lessons I’ve learned over a lifetime of software engineering: it’s about how to write robust, reliable, and above all correct programs.
Writing great tests doesn’t guarantee success by itself, of course, but it’s a very good start. The book has lots of tips about useful testing techniques, lesser-known features of Go’s testing package, testing error handling, designing good test cases, fuzz and mutation testing, test-driving CLI tools, and how to avoid falling into the trap of writing mocks.
This is the first in a three-part series of excerpts from the book, focusing on test suites in Go, what kind of problems you might find with them, and some tips on how to fix them.