Writing testable code isn’t just about writing code that is easy to test, writing testable code is also a way to write higher quality code. If you can test it it is likely to be reusable, loosely coupled and easier to maintain.
The Google Testing Blog, mostly written by Miško Hevery, is amongst the most brilliant things I’ve read on software engineering. If you’re not convinced about the benefits of writing testable code after reading Miško’s articles I think you may be a lost cause. These are my favourites from the last few months:
- Root cause of Singletons
- Singletons are Pathological Liars
- Writing Testable Code
- How to write 3v1l untestable code
- Breaking the Law of Demeter is Like Looking for a Needle in the Haystack
The articles explain testing and good practices in software engineering in a simple, accessible, to-the-point manner without droning on about theory. Great writing and great insight. Read it.