There are lots of mocking frameworks out there for .Net some of them have been superseded by others that are better in everyway. However that still leaves many mocking frameworks that have different styles of usage.
The time it takes to learn all of them well enough to decide witch 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 by asking about the project and myself to help decide on the best mocking framework to use in a given case?
It would also be useful to know why you choose the mocking framework you are currently using and if you are still happy with that choose.
Is there yet a useful vocabulary to use when comparing the styles of mocking frameworks?
(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 Jave)
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 againing on Rhino Mocks for new projects
What have I missed from this summary?
So what drives the choose 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.