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

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.


  1. Paymon says:

    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?


  2. http:// says:


    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).

  3. MOV to DVD says:

    This is a pretty useful tool. It needs a little tweaking, but I like this better than my NAnt solution I did recently.

  4. Ya really very useful book. Thanks for sharing.

  5. rwe rwer I tried to mock a call to a Linq to SQL query, but I am struggling.

  6. Degrees says:

    I have some spermlinks I would like to share with you. It’s the story of how my colleague got the MVC HtmlHelper stuck up his pooper while trying to make a nested loop in the back of his head. I know this will be of great value for you for further editions of ASP.NET MVC.
    psychology degree | education degree | online degree program

  7. Degrees says:

    Thanks for all the great input Stephen. I have tried to use a lot of the architecture you have outlined on MvcCms. We are nearing out first release and would appreciate any feedback on how we might improve the initial architecture. The source is available on codeplex at
    business administration degree | life experience degree

  8. online games says:

    Ishould give it a try. I put Mocking aside as soon as I learnt about NMock.

  9. mmj It looks like DataContextExtensions.cs line 45 of the Save method should pass the primaryKeyName through to Update.

  10. really a nice articles, keep it up