tags:

views:

298

answers:

4

I know this is fairly subjective, but I'm diving into testing and learning about mocking, and I'm trying to figure which framework I should use. If you could please tell me which ones you recommed and most importantly why it's better than others you've used I would aprpeciate. Or if anyone knows where I can get a side-by-side comparison that would aslo be helpful.

+3  A: 

I like RhinoMocks, but it's the only one I've used :}

This looks promising: http://code.google.com/p/mocking-frameworks-compare/

squillman
Is there any particular likes/dislikes you have?
Micah
Sorry, not per se... It was pretty easy to learn and get started with. The developer is hugely active and well respected in the dev community.
squillman
+3  A: 

I'm also using RhinoMocks. I particularly like the AAA (Arrange-Act-Assert) pattern. RhinoMocks makes it easy to set up expectations and check them using this pattern. The syntax uses lambdas and chaining, which fits in very well with LINQ. The similarity in syntax helps with understanding and allows the code to be more compact. the only issue I have with it, and it's not huge, is that in order to mock a method it needs to be virtual. In a sense this is good because it "forces" you to refactor to interfaces, but it can be a pain if an interface isn't really required. It can make mocking some framework classes more difficult. You can get around this by marking your class methods virtual or, with framework classes, creating a wrapper that you mock instead. I don't think these issues are unique to RhinoMocks.

tvanfosson
They aren't, Moq has the same "limitations" in that everything must be abstract, implement an interface, or have virtual members.
TheMissingLINQ
+6  A: 

Moq is the most advanced. It uses all features of .NET 3.5 and C# 3.0. This would be interesting:

eu-ge-ne
+1! I have used NMock, Rhino Mocks and Moq. Moq is BY FAR the best one in my opinion
Brian Genisio
A: 

I've used NMock and think it's excellent. http://www.nmock.org/

However - this is the only one I've used.

Peanut
The problem with NMock, (at least the problem when I used it) was that all of your method names were strings. This means that you don't get any compiler help when you change interfaces. It also means that refactoring tools will not successfully change the tests. Rhino and Moq at least will not compile if you change the interfaces and the refactoring tools work.
Brian Genisio
Fair comment - think it's time to look at the others.
Peanut