parametrized modules and unit testing
Mon Feb 22 14:13:34 CET 2010
Thanks for the suggestion. It seems to meet the needs. I'm planning to
have MB defined as:
enabling me to add internal functions that act as callbacks.
This also fits nicely with eunit.
P.S. Still I would like to have something like a factory pattern, but
that's not what I asked for :-)
On Feb 22, 10:52 am, Vlad Dumitrescu <> wrote:
> On Mon, Feb 22, 2010 at 10:28, pietje <> 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.
> One simple way is to use conditional compilation; in ma use
> -define(MB, mock_mb).
> -define(MB, mb).
> 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,
> erlang-questions (at) erlang.org mailing list.
> To unsubscribe; mailto:
More information about the erlang-questions