Log in

No account? Create an account
The Titfield Thunderbolt Hue and Cry Whisky Galore The Man in The White Suit Previous Previous Next Next
Book Review: xUnit Test Patterns - Refactoring Test Code, by Gerard… - The Titfield Thunderbolt
Heisenberg might have stayed here
Book Review: xUnit Test Patterns - Refactoring Test Code, by Gerard Meszaros
This probably isn't really designed to be read cover-to-cover, but I find that's the only way to at least know what's worth returning to when you dip into it later on. There's quite a lot of good material in here, covering both patterns and anti-patterns (aka "smells"). Curiously, though, whilst Meszaros firmly pushes the agile, test-driven agenda, he backs off from all-out criticism of some patterns as he acknowledges some people prefer them.

Unfortunately, there are places where he misses things. There's a discussion about equality pollution, where an equals method is overridden simply to satisfy test code. In my view, it's often better to override equals for its own sake, and then to test that the implementation is correct, but there's no mention of that. There's a discussion about why databases are "bad" for agile testing, but a reluctant acknowledgement that they're a necessary part of most systems. There's a thorough discussion of many types of test "double", where a dependency is substituted with a simplified implementation for test purposes. I'm always ambivalent of dependency injection and "inversion of control", which are trendy at the moment; it seems to me that in many cases, agility and "inversion of control" in actuality means "cultural revolution", with corresponding consequences for code quality and robustness. "Design for testability" is one of his principles, but over-interpreted it can lead to test code (or at least traces of it) "in production", one of his anti-patterns. Language-wise, most of the examples are from JUnit, though the discussion is generic and some examples are from .Net, Ruby and PL/SQL. There'a lot of repetition, rather like documentaries imported from the USA, where there seems to be a commercial break every 5 minutes.

This is not really a book for the test novice (who hopefully wouldn't be attracted to its title anyway), but for more experienced developers - who probably have some of these ideas in their heads anyway without having formalised them - it's useful as a review and encyclopaedic reference.

Tags: ,

Leave a comment