Unit testing and test-driven development are both very much alive.
The worst thing I remember about my old habits with dishes was how long it would take to do them when I finally got around to it.
Whenever I try to explain unit testing to another developer, I refer to the “smallest unit of work” that’s possible to test.
Last year, I had the opportunity to present at jQuery Portland about unit testing. It was my first non-WordPress speaking event, and it was incredible!
Determining which methods in your application needed testing used to be easy – test everything exposed by the public API. But once you invite other developers to contribute, you are exposing a whole other set of internal APIs to the team. The behavioral consistency of these methods is just as important as that of the public API, so shouldn’t you be testing them too? I would argue you should, even if this internal API consists of private and protected methods. To make life easier, I’ll give you a couple of tools for testing these limited-visibility functions without forcing everything to be declared “public.”
Last time, I argued in favor of the Singleton pattern in WordPress. Singletons make sense in WordPress specifically for several reasons: They live in the global scope without using the already abused/overused global keyword As a distributed application maintained by several hundred developers, they prevent problems that likely arise from others misusing your code But […]