There are lots of mocking frameworks out there for .Net. There is no clear winner that has superseded the others in every way. The leading mocking frameworks also have many different styles of usage.
The time it takes to learn all of the mocking frameworks well enough to decide which to use is unreasonable. I don’t believe that we have yet reached a stage that we can talk about the best mocking framework. So what questions should I be asking, both about the project, and about myself, to help decide on the best mocking framework to use, in a given case?
It would also be useful to know why you chose the mocking framework you are currently using and if you are still happy with that choice.
Is there a useful vocabulary to use when comparing the styles of mocking frameworks?
(Note: I have limited this question to .Net as Java does not have attributes or lambda expression, so I hope the mocking frameworks can be better for .Net then Java)
Summary so far:
- If you need to mock static method, or none virtual methods then the only reasonable option is TypeMock, however it is not free and does not drive you towards a good design.
- Rhino Mocks is a very good option if you are doing TDD, .e.g the objects you wish to mock implement interfaces. At present it seems to be the "market leader"
- Moq (introduction) should be considered if you are using .NET 3.5 Moq may be gaining on Rhino Mocks for new projects
What have I missed from this summary?
So what drives the choice between Rhino Mocks and Moq, if you are using .NET 3.5?
see also:
- What C# mocking framework to use?
- What are the capabilities of Moq and Rhino.mocks?
- What are the real-world pros and cons of each of the major mocking frameworks?
“What should I consider when choosing a dependency injection framework for .NET?” may also be of interest as it asks the “other side” of the question.