O'Reilly logo

The Art of Unit Testing, 2nd Edition by Roy Osherove

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A.1. Isolation frameworks

Mock or isolation frameworks are the bread and butter of advanced unit testing scenarios. There are many to choose from, and that’s a great thing:

  • Moq
  • Rhino Mocks
  • Typemock Isolator
  • JustMock
  • Moles/Microsoft Fakes
  • NSubstitute
  • FakeItEasy
  • Foq

The previous edition of this book contained the following tools, which I’ve removed due to being out of date or relevance:

  • NMock
  • NUnit.Mocks

Here’s a short description of each framework.

A.1.1. Moq

Moq is an open source isolation framework and has an API that tries to be both simple to learn and easy to use. The API was one of the first to follow the arrange-act-assert style (as opposed to the record-and-replay model in older frameworks) and relies heavily on .NET 3.5 and 4 features, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required