[erlang-questions] How to meck?

Bohuslav Svancara <>
Wed Jan 11 11:24:53 CET 2012


Thanks for your help, Magnus. It works fine now.

Bob

2012/1/11 Magnus Klaar <>

> Hi!
>
> Comparing the output in the two posts, the first one returns 'a' from
> call_a() and the return value you specified using meck:expect/4 from the
> a() function, the second one shows that both call_a() and a() returns the
> value you specified.
>
> If you want to return  "result_from_mocked_a" from these functions you
> must invoke meck:expect/3 or /4 as:
>
> meck:expect(meck_module_for_test, a, 0, "result_from_mocked_a") or
> meck:expect(meck_module_for_test, a, fun() -> "result_from_mocked_a" end )
>
> MVH Magnus
>
> On Wed, Jan 11, 2012 at 12:27 AM, Bohuslav Svancara <>wrote:
>
>> Thank you, but it does not help.
>>
>> ---------- modified tested module:
>>
>> -module(meck_module_for_test).
>> -compile(export_all).
>> a() -> a.
>> call_a() -> *meck_module_for_test:a().* % changed line
>>
>> -------  testing module "meck_test" is the same (se below)
>>
>> Result:
>>
>> 1> meck_test:test().
>> Result of call_a: #Fun<meck_test.1.84433456>
>> Result of a: #Fun<meck_test.1.84433456>
>> Valid: true
>> ok
>>
>>
>> Bob
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120111/2a0d7272/attachment.html>


More information about the erlang-questions mailing list