Do we really need stubs?

145 views
Skip to first unread message

Marcelo Oliveira

unread,
Sep 10, 2012, 6:12:34 PM9/10/12
to rhino...@googlegroups.com

Hi there!

If it's possible to change mock behaviour in Rhino Mocks using mock.Stub().Return(), why do we need Stubs anyway?

What do we lose by always using MockRepository.GenerateMock()?

One big benefit of using Mocks instead of Stubs is that we will be able to reuse the same instance among all the tests keeping them cleaner and straightforward.

The moq framework works in a similar way... we don't have different objects for mocks and stubs.


tks in advance!
Marcelo Oliveira

Luis Ferreira

unread,
Mar 1, 2013, 6:22:58 AM3/1/13
to rhino...@googlegroups.com
Exactly my current question (!)

Apparently there's a semantic difference, in that «you should use a mock when you are going to verify that something happened on the object, like a method was called. You should use a stub when you just want the object to be involved in the test to return a value but it is not the thing you are testing» (http://stackoverflow.com/questions/2536551/rhino-mocks-difference-between-generatestubt-generatemockt)

And also «only mocks insist upon behavior verification» (http://stackoverflow.com/questions/1288168/when-to-use-stubs-and-mocks)

I can understand it but couldn't yet "grok" it, in the sense that in practice I feel Mocks go beyond Stubs in functionality. *sigh*
Reply all
Reply to author
Forward
0 new messages