Wednesday, January 21, 2015

Alternatives to Microsoft Fakes

If your development team is using an edition of Visual Studio lower than Visual Studio 2013 Premium Edition (such as Visual Studio 2013 Professional), you will not have access to using Microsoft Fakes.

Even if you have access to Visual Studio 2013 Premium Edition, you may not be happy with the way in which Microsoft Fakes works compared to Mocking frameworks such as Moq or Rhino Mocks.

Well, unfortunately, one of the limitations of most Mocking frameworks such as Moq or Rhino Mocks is that they can only Mock code that is derived from interfaces or have their methods/members marked as virtual.

If the code does not fit into either of these categories, then a framework such as Microsoft Fakes allows you to fill in those gaps where you do not have control of the code (such as 3rd party code or the underlying .NET Framework classes).

The problem with the way that Microsoft Fakes works, however, is that it requires "Fakes" to be generated from all of the code references that you need to Fake.  This process adds additional time to the overall build process and can differ from developer machine to developer machine which makes it very unappealing overall.  It also does not have the same readability constructs of most Mocking frameworks.

Well, fortunately, there are alternatives to using Microsoft Fakes:

  1. Telerik JustMock: - This Mocking Framework is provided by Telerik who also provides a host of controls for the Visual Studio IDE.  It offers the same types of capabilities as are offered by Microsoft Fakes with the readability of standard Mocking frameworks and the requirement to generate "Fakes" files for all assembly references.
  2. TypeMock Isolator: - TypeMock has been around for a number of years and has long been a choice for many developers that needed to work around the limitations of most other Mocking frameworks.
Both Telerik JustMock and TypeMock Isolator offer free versions of their Mocking libraries, however, the free versions have many of the same limitations as the free, open-source versions of Mocking frameworks such as Moq and Rhino Mocks making the free versions limited in their usefulness.

You can compare the editions yourself here:

JustMock Edition Comparison

TypeMock Isolator Edition Comparison

No comments:

Post a Comment