Rhino Mocks: Stub & Mocks. What is the difference
I'm using Rhino Mocks in my unit test.
I would like to know the difference between STUBS and MOCKS (mocks.Stub<T>()
and mocks.StrictMock<T&g开发者_如何转开发t;()
).
I think it had been asked before.
It is generally the same with the following differences:
- Strict Mocks throw exceptions on each call which had not been expected
- Dynamic Mocks accept unexpected calls und just return default values (eg. null)
- Stubs are like dynamic mocks but have "property behaviour" turned on by default. This allows writing and reading properties like fields, but doesn't allow
Stub
,Expect
norAssertWasCalled
on properties. This behaviour can also be configured on a normal Mock too. But for stubs it is the default.
Since Rhino changed to AAA syntax, it is discouraged to use Strict Mocks, since they make test code very hard to maintain.
Similar questions:
- What are the differences between mocks and stubs on Rhino Mocks?
- Rhino Mocks - Difference between GenerateStub<T> & GenerateMock<T>
I can't find the information about the Rhino implementation, so I don't mark this question as duplicate.
精彩评论