launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #02647
Re: Writing stubs made easy
On Tue, Feb 16, 2010 at 10:03 PM, Jeroen Vermeulen <jtv@xxxxxxxxxxxxx> wrote:
> A FakeMethod can take the place of any function or method, and:
>
> - Return a constant value.
> - Raise an exception instead.
> - Tell you how many times it's been invoked.
> respectively. It saves time writing tests, but also lets your test get to
> parts it couldn't normally reach because you can mock up so many things so
> quickly. Plus you can unit-test more classes in fast tests using fewer
> layers, with all the complex work ripped out and exercised only in
> integration tests.
>
> An ancestor of this class allowed me to write unit tests for our failing EC2
> scripts a few months back, and this time I hit a second big use-case with
> the buildfarm work. Hope you enjoy it as I do!
How does this compare to Gustavo's mocker library (already available
thanks to buildout).
--
Stuart Bishop <stuart@xxxxxxxxxxxxxxxx>
http://www.stuartbishop.net/
Follow ups
References