[erlang-questions] Mocking in Erlang

Jeremy Wall jeremy@REDACTED
Tue May 27 03:46:04 CEST 2008


what is the typical way to handle the case where your module uses ibrowse
say.

is the best practice in testing just to not mock ibrowse?
or do you typically just isolate the ibrowse calls in a small untested
function and test everything else as normal?
or is there some other trick I dont know about yet?

On Mon, May 26, 2008 at 6:41 AM, Dominic Williams <
erlang-dated-1212234074.c1eaa3@REDACTED> wrote:

> Hi Jeremy,
>
> > While browsing the erlang-questions list archives I found mention that
> > someone had written a Mocking Module for erlang that would mock
> processes.
> > I'm wondering if that ever got published anywhere or if there are other
> > mocking frameworks for erlang that have been used. I love TestFirst
> > development but it would be a lot easier if I could mock outside sources
> > when I write my tests.
>
> Because the "protocol" (or alphabet) of an Erlang process is not
> formalised (there is no interface definition), it is completely trivial to
> to implement a mock of a process (with just enough messages for the
> context of the test), so I write mocks all the time without needing a
> framework.
>
> Sometimes, I pass the test's self() directly and send/receive from the
> test function. Sometimes, the test is a bit cleaner if I spawn a fun() ->
> ... end that is hard-coded to receive and/or send the exact messages I
> need to make my test work.
>
> It's so straightforward that I can't imagine a framework would do any good.
>
> Regards,
>
> Dominic Williams
> http://dominicwilliams.net
>
> ----
>
>


-- 
Jeremy Wall
http://jeremy.marzhillstudios.com
Jeremy@REDACTED
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080526/359ab492/attachment.htm>


More information about the erlang-questions mailing list