jimmy keen

on .NET, C# and unit testing

Mocking frameworks comparison

December 13, 2014 | tags: unit-testing mocking c#

You might have been redirected to this page.

Out with the old, in with the new

While ago I used to run this post series called “Mocking frameworks comparison” where I was comparing API of RhinoMocks, Moq and FakeItEasy. Long story short, it is no more.

Why have I decided to bury the series? I think we should be using modern frameworks, like FakeItEasy, Moq or NSubstitute. Comparing them with each other makes little sense as they are nearly identical both functionality-wise and syntax-wise (on top of that they all have excellent documentation and active community). Comparing them with RhinoMocks makes little sense as Rhino is old and no longer developed framework1 with often confusing syntax spanning across different version2.

Which framework to use?

The question remains. Rather than giving you straight answer I will answer a different question instead. Which framework you should stay away from? - RhinoMocks. Why?

  1. Its API is old, unpleasant and undocumented. It will make learning (it) harder and your tests will be more difficult to follow.
  2. It is no longer actively developed (regardless of recent attempts).
  3. It is one-man show (who might get bored and leave at some point).
  4. It is in alpha phase (since spring this year).

You do not want such library in your project. Rhino was excellent library but that was 5 years ago. Nowadays, there are simply better kids on the block (I am thinking FakeItEasy, Moq and NSubstitute). Use either of them. As for me, I stick with FakeItEasy as it is the exact opposite of Rhino’s don’ts3.

  1. I am aware that there has been recent activity and an attempt to resurrect Rhino but after initial excitement it does not seem to be that continuous anymore.

  2. Record-Replay users, anyone?

  3. Simply check FakeItEasy project page on GitHub (including recent activity) and you will see what I mean.