<p>A while ago I read the <a href="http://www.martinfowler.com/articles/mocksArentStubs.html" rel="nofollow noreferrer">Mocks Aren't Stubs</a> article by Martin Fowler and I must admit I'm a bit scared of external dependencies with regards to added complexity so I would like to ask:</p>

<p>What is the best method to use when unit testing?</p>

<p>Is it better to always use a mock framework to automatically mock the dependencies of the method being tested, or would you prefer to use simpler mechanisms like for instance test stubs?</p>

Read Luke Kanies' discussion of exactly this question in
this blog post
. He references
a post from Jay Fields
which even suggests that using [a equivalent to ruby's/mocha's] stub_everything is preferrable to make the tests more robust. To quote Fields' final words: "Mocha makes it as easy to define a mock as it is to define a stub, but that doesn't mean you should always prefer mocks. In fact, I generally prefer stubs and use mocks when necessary."