[erlang-questions] Mocking in Erlang

Per Melin per.melin@REDACTED
Tue Jun 3 19:54:43 CEST 2008


2008/6/3 Christian S <chsu79@REDACTED>:
> However, we can suffer from hard-coding the function used in spawning
> a process. If our gorilla process has a spawn_link(fun banana:start()
> end) for the Consumable, then it is going to be difficult to have it
> use our mock Consumable.

Not necessarily. Since modules aren't linked the gorilla module will
call *whatever* module that calls itself banana at the time the test
runs, right? So what if your test setup purges the real banana module
and loads a mock banana with code:load_abs/1? It won't allow you to
use a generic consumable module though.


> IBrowse:request(URL)

I think that calling a function with a variable module like that is
still slower than a normal qualified function call.

I did a quick test now and (unless I messed up) it was about 5x
slower. In most cases that won't matter, but it's something to keep in
mind.



More information about the erlang-questions mailing list