Book Review: The Art of Unit Testing by Roy Osherove

by Aaron 13. September 2011 22:19

Let me start off by saying, I didn't seek this book out.  It was recommended by a friend after I read "Working Effectively with Legacy Code" by Michael Feathers (see my review here).  With that, here's the bad, the good, and the summary (in that order!).

The Bad

First, the bad.  The book (official site) itself wasn't bad.  Unfortunately, I didn't learn much from the book.  I had followed up Michael Feathers book with this one, and maybe that was the issue.  Michael Feathers book was densely packed with tons of information.  "The Art of Unit Testing" felt pretty light in comparison.

There was nothing really ground breaking about the book.  A good amount of the information presented is information that can be easily found around the web, in samples from the unit testing tools available, and in other books that maybe aren't even about unit testing (link). It made more than a couple of references back to Michael Feathers book encouraging the reader to maybe go look at that book.

The Good

It was written well and easily understood. I feel like it's organized well.  It also goes into detail about techniques you can use to try to integrate unit testing into your organization.  The author himself has been through the scenario multiple times and is able to relate his experiences.

The first thing that was new to me was how to hide some of the constructors from the public interface, but make them visible for testing.  Declare them as internal and add the InternalsVisibleTo attribute in the AssemblyInfo file.  That helped settle a disagreement I was having with one of my former coworkers.  He felt reflection should be used to set fields and properties instead of using dependency injection techniques like overloaded constructors.  Declaring the constructors as internal gave him more of a warm, fuzzy feeling than having them public, and it let me do what I felt was best.  So thanks for settling that Roy!

The author was working for Typemock while writing the book.  He even gave that disclosure multiple times throughout the book in an attempt to dissuade the user from feeling like he was secretly trying to sell the reader on Typemock products like Isolator.  He did give lots of examples using Typemock Isolator, but they were to demonstrate what's possible with various tools.  Typemock Isolator definitely has a lot of power and features, as it should since it's a commercial product.

While a lot of examples were around Typemock Isolator, many (and probably more) examples were given using Moq and Rhino Mocks.

The other place that I found useful information was in the appendices.  The appendices went through and described various tools that can fill various needs in testing (unit, integration, and even acceptance).  The listings and descriptions were really good.  It pointed out some tools that I didn't know about and plan on investigating.  For now though, I'm pretty happy with xUnit.net, MS Test, and Moq.

Summary

Overall the content in the book really felt too too basic for me.  Maybe that's my fault for following up the Michael Feathers book with this one.  Maybe I expected the same level of detail and amount of content that was in my previous read.  Maybe I'm just wicked smart!  Who knows?

I wouldn't recommend this book to anybody except people that are looking to get started with unit testing and haven't read Michael Feathers book yet.  I feel like this might be a better book to start with and followed up with Michael Feathers book "Working Effectively with Legacy Code".  Reading in that order may lead to better enlightenment.

While it was pretty basic, I did get some useful information out of it.  Now though, it'll probably just collect cyber dust sitting on my cyber bookshelf (I got the eBook version if you're wondering what the hell I'm talking about).

Tags: , , , ,