Hello!<br>I am trying to use meck, but have no luck.<br>Can you help me, please?<br><br>Erlang version: Erlang 5.9/OTP R15B <br>
<br>---------- tested module:<br>-module(meck_module_for_test).<br>-compile(export_all).<br>a() -> a.<br>call_a() -> a().<br><br>------------------------- testing module:<br>-module(meck_test).<br>-compile(export_all).<br>
test()-><br> ok = meck:new(meck_module_for_test,[passthrough]), % Docs says: Retains the original functions, if not mocked by meck. <br> <br> % Mock "a()" which is called from call_a().<br> ok = meck:expect(meck_module_for_test, a, 0, fun() -> "result_from_mocked_a" end ),<br>
<br> Result = meck_module_for_test:call_a(),<br> io:format("Result of call_a: ~p~n",[Result]),<br> <br> Result_A = meck_module_for_test:a(),<br> io:format("Result of a: ~p~n",[Result_A]),<br>
<br> Valid = meck:validate(meck_module_for_test),<br> io:format("Valid: ~p~n",[Valid]),<br> <br> meck:unload(meck_module_for_test), <br> ok.<br><br>--------------------- result of meck_test:test():<br>
Result of call_a: a<br>Result of a: #Fun<meck_test.1.126597877><br>Valid: true<br>ok<br>-----------------------------<br><br>I believe that call_a() should call a mocked version of a() which should return "result_from_mocked_a".<br>
So the result from call_a() shoud be:"result_from_mocked_a"<br>But my results are different.<br><br>Can you help me, please?<br><br>Thanks,<br>Bob<br>