More Muc Than You Can Handle

Book Review - The Art of Unit Testing by Roy Osherove

The Art of Unit Testing Book Cover In a recent splurge I purchased 4 books from Manning Press with one of them being The Art of Unit Testing by Roy Osherove.

I would categorize myself as relatively new to unit testing. My first hands on testing was when I took the Nothing but .Net bootcamp with JP Boodhoo but he emphasized BDD style tests. I saw the benefit of BDD but didn’t feel I had the know how to implement them properly. About 3 months ago I started writing tests in a more unit test like fashion and things started clicking.

This book felt like an Assertion of what I’ve learned over the last year. As I read the book I kept finding stories I could relate to. In my attempts to apply unit testing to my own code, I experienced nearly everything Roy talks about in this book.

Chapter 5 was great a explaining the differences between the terms Stub and Mock. What I liked was how he provided samples of manual stubs and mocks to give the reader a peak under the curtain as to what a mock (err faking, Roy’s personal word preference) framework does for us. I can understand how the work mock is overloaded now, and can appreciate the proper terminology and it helps when explaining these concepts to others.

For me Chapters 6 and 7 are where I got the most out of the book. Through all my reading of testing on-line, I found it quite simple because the scope of the demos were so small. I felt these two chapters armed me with some good principals on organizing tests and treating them just as important as my production code.

All in all this was one of the easiest programming books I’ve ever read. Roy’s tone was fun (especially his little jab at Ayende), but wasn’t so opinionate that it sounded preachy. In fact I felt comfortable making my own opinions that extend his foundations. Roy presented the material in a way that seems like he assumes you’re not an idiot. There wasn’t a lot of “hand holding” which can be found in other entry level books. He provides ample resources for those that want more instruction on certain topics which creates a good pace for the reader.

As for the negatives: I wish it was a little longer. I don’t know why, but I felt that there was more to say on a lot of topics. Perhaps more examples, which could seem a bit repatitive, but could be skipped by those who got the message. I also didn’t like how TypeMock was being pushed heavily and the disclaimer that Roy worked for TypeMock didn’t come in until near the end.

I would reccomend this book to anyone who is new to unit testing. I think I read the book at almost a perfect time. I knew enough that I could see past the trivial example to the message he’s delivering, but not enough to skip all the material because it was so obvious. A seasoned unit tester might not get as much value from this book, but I would urge them to get it anyways so they can loan it to those they work with who are new to testing.

A great prelude to reading this book is to watch Roy review the test suites for the following projects:

Nerd Dinner Asp.Net MVC Microsoft Unity

Be warned, you’ll be watching a grumpy Roy at 2am :-). Roy also has a great blog and is active on twitter as well.