---
title: "Choosing a Mock Object Framework"
url: "https://osherove.com/blog/2007/4/26/choosing-a-mock-object-framework.md"
canonical: "https://osherove.com/blog/2007/4/26/choosing-a-mock-object-framework.html"
published: "2007-04-26T15:10:16"
updated: "2007-04-26T15:10:16"
tags: ["Agile", "Agile Related", "Art Of Unit Testing", "Unit Testing"]
author: "Roy Osherove"
description: "Update : I've added a simple Poll at the bottom of this post which you can answer on your most used frameworks. ----------------------- My upcoming book is going forward ever so slowly, mostly due to my beautiful new…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Choosing a Mock Object Framework

By Roy Osherove April 26, 2007 In [Agile](https://osherove.com/blog/category/agile), [Agile Related](https://osherove.com/blog/category/agile-related), [Art Of Unit Testing](https://osherove.com/blog/category/art-of-unit-testing), [Unit Testing](https://osherove.com/blog/category/unit-testing)

**Historical article** · Originally published April 26, 2007; technical details may be outdated.

**Update**:

I've added a simple Poll at the bottom of this post which you can answer on your most used frameworks.

\-----------------------

My [upcoming book](http://www.artofunittesting.com/) is going forward ever so slowly, mostly due to my beautiful new son, Itamar, which seems to be changing everyone's priorities, by simply being the cutest little person that he is (at 4 months).

Still, I'm struggling to bring myself to write more, and it's a tough job. I simply feel less strongly about everything technical these days, but it's slowly coming back to me.

I'm currently struggling with Chapter 5, which is currently titled "Mock Object Frameworks". My current dilemma is a pretty important one, so I thought maybe you guys can help me with directions on my decision.

**My question to you**: Which [Mock Object](http://en.wikipedia.org/wiki/Mock_Object) framework should I use for Mocking examples in my book?

There are my current candidates:

**1\.** [**NUnit.Mocks**](http://nunit.org/) **(yes, there is such a thing!** [**here's an example**](http://www.socialanimal.com/2005/07/05/nunit-mocks/)**)**

Simple, Easy, and straightforward, this feels like the perfect framework to start the novice Mocker off with, especially since NUnit plays a role earlier in the book. However, I'd also like to show later on more advanced stuff that NUnit.Mocks does _not_ support like events, generics etc, which other frameworks do. I'm not sure how great I feel about changing the mock framework from underneath the reader's nose mid way... what do you think?

**2\.** [**NMock**](http://nmock.org/nmock1-documentation.html)

This is one of the "standard" frameworks for mocking in .NET, and many people use it, but it's getting old. It has a new version Nmock2, which I'm considering, but that hasn't been updated in over a year (see next bullet)

**3\.** [**NMock2**](http://nmock.org/index.html)

Looks very promising, and sounds great, but the Downloads section of SourceForge seems to only have a version from May 2006, a year ago! Does _anyone_ know what' sup with this framework's code? Is it actively maintained? It has [a continuous build cycle](http://ccnetlive.thoughtworks.com/ccnet/server/local/project/NMock/ViewProjectReport.aspx), I know, but is it actually progressing somewhere? I wouldn't want to write about a framework that's on it's way out one way or another. Thoughts?

**4\.** [**EasyMock**](http://sourceforge.net/projects/easymocknet/)

One of the "Standards". I like it. it's nice and easy, but some things are missing (that I'm missing from it, at least. Maybe they are there?) - Support for checking parameters with custom matchers (assert that the parameter passed in contains some string, for example, or check a property value on a passed in object).  Plus, it's latest version is very old from 2004.

**5\.** [**Rhino Mocks**](http://www.ayende.com/projects/rhino-mocks.aspx)

[Oren Eini](http://www.ayende.com/) is doing a great job with this framework, and I think it's the only one that seems to be keeping up with the latest features in .NET, other than TypeMock. Plus, it's totally free to use (as are all the previous ones). It's also the only one _other than TypeMock_ which does not require you to input strings for method names you'd like to mock, which is cool. It's compelling to use it but the project is currently maintained by just one person. If Oren decides to drop it, or for any reason stop working on it, the book might turn out outdated quite quickly. Plus, it's not very widely used, though it seems to be gaining in popularity.

**6\.** [**TypeMock**](http://www.typemock.com/)

Great framework, with lots of features. _No need to use strings for method names like in RhinoMocks._ Also, not very widely known, but gaining in popularity quickly, mainly because of it's ability to mock _anything_ including statics, privates and events, without even requiring you to inherit or implement any interfaces or virtual methods. It's almost magical in that sense(or even too powerful), but it also support the "traditional" way of mocking objects, just like all the others. Sadly, it's Commercial, and I'm not sure how well that would be received by my readers.

What do you guys think? What framework is a good fit for a book about Unit Testing and Mock Objects?

Write a comment, or take this quick Poll:

Embedded Flash media from the original post is no longer playable.

## More in Agile

[All posts in Agile](https://osherove.com/blog/category/agile)

- Apr 27, 2007

    ### [See you At the DevTeach Agile Track!](https://osherove.com/blog/2007/4/27/see-you-at-the-devteach-agile-track.html)

- Apr 27, 2007

    ### [Poll: What Mock Frameworks do you use?](https://osherove.com/blog/2007/4/27/poll-what-mock-frameworks-do-you-use.html)

- Mar 16, 2007

    ### [Remote Pair Programming with collaborative text editors](https://osherove.com/blog/2007/3/16/remote-pair-programming-with-collaborative-text-editors.html)

- Mar 13, 2007

    ### [Test Reviews Vs. Code Reviews - Some Helpful Tips](https://osherove.com/blog/2007/3/13/test-reviews-vs-code-reviews-some-helpful-tips.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
