Book Review: The Art of Unit Testing

I stumbled across The Art of Unit Testing by Roy Osherove while researching Mock Object frameworks that can be used with ASP.NET MVC. Even though the author is still in the process of writing the book, you can download an early draft of this book at http://www.manning.com/osherove/.

This is a fantastic book for learning about Mock frameworks such as Rhino Mocks. One of the nicest features of the book is the author’s clearly worded definitions of many terms that you encounter when working with Mock object frameworks. For example, the book contains a valuable section that distinguishes between Stubs and Mocks. He also provides clear explanations of different techniques for performing Dependency Injections and creating Seams.

The book concentrates on Rhino Mocks. He delves into the gritty details of how and when to use Rhino Mocks to simulate objects. He provides walkthroughs that demonstrate how to use Rhino Mocks to test whether expected object methods have been called, expected object properties have been set, and expected object events have been raised.

The book also has a useful section that compares the different Mock Object frameworks. He compares NUnit.Mocks, NMock, NMock2, Type Mock, and Rhino Mocks (This section convinced me that I need to check out Type Mock).

Even though the book is not finished, I already found it to be extremely useful. As far as I know, it currently is the only book that compares different Mock Object frameworks available in the .NET universe.

2 Comments

  • Sounds good,

    I should give it a try. I put Mocking aside as soon as I learnt about NMock. Does this book introduce a fully typed, compile-time-checked way of mocking?

    Thanks

  • @Paymon,

    Yes for Rhino Mocks. Roy Osherove does a good job of discussing the issue that you raise. With Rhino Mocks, you setup expectations by calling the actual methods of the object that you are mocking and not by passing a string parameter that represents the method (as you would with NUnit.Mocks).

Comments have been disabled for this content.