Subscribe to this Blog

Subscribe to this Blog

Book Review: The Art of Unit Testing - Stephen Walther on ASP.NET MVC

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.

Published Friday, March 14, 2008 3:21 AM by swalther
Filed under: , , ,

Comments

# re: Book Review: The Art of Unit Testing

Friday, March 14, 2008 9:48 AM by Paymon

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

# re: Book Review: The Art of Unit Testing

Friday, March 14, 2008 12:31 PM by swalther

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