[mocha-developer] how does Mocha compare in terms of classical vs mock-based testing, and stubbing???
dchelimsky at gmail.com
Mon Feb 5 07:46:05 EST 2007
On 2/4/07, Greg Hauptmann <greg.hauptmann.ruby at gmail.com> wrote:
> Hi guys,
> I've just been reading Martin Fowler's article re mock versus
> he compares traditional TDD testing techniques with mock based
> testing. I'd be interested in comments from a ruby on rails perspective in
> terms of this and Mocha? For example:
> a) Do you see Mocha as a robust way to test Ruby on Rails based apps?
Yes - though I think of mocking as one tool among many in a robust
> b) Why would one use Mocha over traditional non-mock object based testing
> for Ruby on Rails?
Interface Discovery!!!!!! Read http://jmock.org/oopsla2004.pdf for
more info on that.
> c) Is Mocha a good choice for stubbing out other components that the rails
> app may interact with, for the purpose of testing?
Short version: Yes.
Longer version: A guideline that I like to follow is to wrap 3rd party
APIs with thin adapters that provide context-appropriate method names
and only those that your app needs. Then you mock your own API, not
the 3rd party API. You still need to test your adapter, but that test
is isolated from the tests that are about your application and what it
> mocha-developer mailing list
> mocha-developer at rubyforge.org
More information about the mocha-developer