parametrized modules and unit testing
pietje
pieter.rijken@REDACTED
Mon Feb 22 14:14:35 CET 2010
Hi,
Thanks for this alternative. I'll keep it in mind for the more complex
modules I have.
pieter
On Feb 22, 1:18 pm, Ken Robinson <kenrobinsons...@REDACTED> wrote:
> Hi,
> I've not used this module but it appears to give the behavior you want.http://frihjul.net/emock
>
> regards,
> Ken.
>
>
>
> On Mon, Feb 22, 2010 at 7:52 PM, Vlad Dumitrescu <vladd...@REDACTED> wrote:
> > On Mon, Feb 22, 2010 at 10:28, pietje <pieter.rij...@REDACTED> wrote:
> >> Suppose I have 2 modules, say ma and mb, and that module ma uses
> >> (imports) module mb.
> >> I'm trying to figure out in Erlang how to write unit tests for module
> >> ma that do not depend on the particular
> >> implementation of functions in module mb.
>
> > Hi,
>
> > One simple way is to use conditional compilation; in ma use
>
> > -ifdef(TEST).
> > -include_lib("eunit/include/eunit.hrl").
> > -define(MB, mock_mb).
> > -else.
> > -define(MB, mb).
> > -endif.
>
> > and make all calls to mb via ?MB. (Of course, you'll have to implement
> > a mock_mb module).
>
> > A more advanced way would be to have a central mock server where you
> > can register a fun for each mocked function (in any module) and use
> > error_handler:undefined_function to use these registered funs instead
> > of the real ones. This is quite complex to implement, though.
>
> > best regards,
> > Vlad
>
> > ________________________________________________________________
> > erlang-questions (at) erlang.org mailing list.
> > Seehttp://www.erlang.org/faq.html
> > To unsubscribe; mailto:erlang-questions-unsubscr...@REDACTED
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> Seehttp://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscr...@REDACTED
More information about the erlang-questions
mailing list