views:

75

answers:

1

I understand the difference between a Mock and a Stub.

But different types of Mocks in RhinoMock framework confuses me.

Could someone explain the concepts of Mocks Vs StrictMocks Vs DynamicMocks in terms of RhinoMock framework.

your answers are greatly appreciated.

+5  A: 

A strict mock is a mock that will throw an exception if you try to use any method that has not explicitly been set up to be used.

A dynamic (or loose) mock will not throw an exception if you try to use a method that is not set up, it will simply return null a default value from the method and keep going.

It is highly recommended to use dynamic mocks, as strict mocks generally turn out to be a maintenance nightmare. Here's a good blog post that has a code example of strict vs. dynamic, and why strict mocks are usually a bad idea.

womp
Nit-pick -> "return null" should be something like "returns the default value for the return type"
Merlyn Morgan-Graham
@Merlyn Morgan-Graham - great point :)
womp
@womp, @Merlyn Morgan-Graham : Thanks a lot guys for the lightning fast response. much appreciated.
IG105