When most developers think about books on testing, they think about books that highlight things like “test driven development” or “how to build a test for X.” There are lots and lots of testing books out there that supposedly teach us how to write tests and reach milestones like “100% test coverage.” But at the risk of sounding risque, testing is very similar to sex: more people claim to do it than actually do, most people claim more experience with it than they actually have, and more people have advice on the subject than probably should.
This is not true of Chris Hartjes’ book, “The Grumpy Programmer’s Guide To Building Testable PHP Applications”. When I asked Chris if I could review his book, I expected a step-by-step guide to writing tests. What I got was a step-by-step guide to building an application that COULD be tested. There’s a big difference, and it’s important to understand the distinction.
Writing tests is certainly hard; Chris makes no bones about this. But testing is made unnecessarily difficult by bonehead developers who consistently write applications that are resistant or impossible to test. It is in this framework, then, that Chris focuses most of his energies: writing (or rewriting) an application to be testable. Rather than embracing a particular methodology, framework or behavior, Chris adopts the tactics and techniques that work to build applications that can be tested, and shows exactly how to test them along the way.
Chris’ book isn’t perfect by any stretch and it won’t solve every one of your test or application development problems. That’s not it’s purpose. It’s purpose is to provide examples and guidelines for building an application that won’t cause you to rip your hair out when you go to test it. Chris walks a fine line, but his experience with testing and application development gives him the credibility necessary to advise and instruct in this area.
There are many words of wisdom in the book, from “if it’s not yours, wrap it up” (on building wrapping layers) to “testing is good; testable applications are better.” His admonition that the development environment and the deployment environment should be as similar as possible helps eliminate those “it worked on my machine!” moments, and is something I’ve believed in for years.
The book is for sale at LeanPub for a suggested price of $15. In truth, it’s worth twice it’s price, and I highly recommend it to anyone who struggles with developing testable applications.
Frustrated with your company’s development practices?
You don't have to be!
No matter what the issues are, they can be fixed. You can begin to shed light on these issues with my handy checklist.
Plus, I'll help you with strategies to approach the issues at the organization level and "punch above your weight."