[mocha-developer] When to stub/when to mock (was Rails functional testing and Mocha)
jamesmead44 at gmail.com
Mon Mar 5 10:52:44 EST 2007
On 05/03/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> I have a different perspective on when to use stubs and when to use
> mocks and I'm curious as to your thoughts about it.
> I like to put stubs in setup, regardless of whether they are commands
> or queries, and mock expectations in test methods (specify blocks in
> rspec). This keeps the noise of what is necessary but uninteresting
> (from the perspective of the tests) out of the way of the test
> methods, which can focus entirely on the interesting bits.
> The motivation is the same as Nat Pryce's - expecting only the
> interesting bits will make tests less brittle - but the resulting
> principle revolves on a different axis.
> Thoughts on this?
I don't think we are thinking very differently.
I think of the stubs as providing an environment for the object under test.
Whether and how the object under test chooses to query this environment is
an implementation detail. So I stub rather than expect. Does that make
I'm not sure what you mean by "revolving on a different axis".
More information about the mocha-developer