Tuesday, April 29, 2008

xUnit Test Patterns

I picked up a copy of a new book called xUnit Test Patterns

Some of the developers I have given it to have said it was like gold to them with the help from Design Patterns

Built with a similar structure as the Design Patterns, the reference material at the front and back covers helped to fill in the gaps. The inside front cover shows the design patterns used to create xUnit fixtures and suites. At the back is something completely different - its like a Q&A of when people talk to you about why they can't put xUnit into their applications. My favorite section is "Legacy code cannot be automatically unit tested". Page 365, BAM! Often when I use this lookup, it start a discussion with a developer to begin thinking differently.

Its a nice all encompassing view of how to unit test applications. Although its not new, its nice to have it one place. I think these are one of those books that will be good 10 years from now because of the solid use of patterns over technologies. I'm not a fan of having a huge reference guide for many languages. I use pocket references mostly when I need reference material (or just look it up online). Its a very nice indispensable tool to look up all the different types of unit test structures and patterns in one easy location.

Check it out the reviews for yourself.

For quick reference, here are comments on some of the chapters:

  • Chapter 2: Test Smells - I like this chapter because it explains why code smells and how to recognize where to apply tests

  • Chapter 3: Goals of Test Automation

  • Chapter 7: xUnit Basics - this has saved me a few times now on having to explain to developers how to integrate unit tests into legacy applications. I'm sure I'll get some more running ground on this chapter in the next few years

  • Chapter 25: Database Patterns - this is something I have not got a lot of ground on. People still tell me they cannot abstract out databases. I don't believe you need to, you just should consider the contents of this chapter in order to unit test your database.
To get a copy for yourself, you can order it online or take a look at the online version for free. Again, I like free stuff, so go and educate yourself for free!