Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meck:unload is undefined? #72

Closed
ostinelli opened this issue Jul 23, 2012 · 3 comments
Closed

meck:unload is undefined? #72

ostinelli opened this issue Jul 23, 2012 · 3 comments

Comments

@ostinelli
Copy link

Using this module, and R15B01:

-module(example).
-compile(export_all).

get_config() ->
    mocked:myfun("test.cfg").

-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").

get_config_test_() ->
    meck:new(mocked),
    meck:expect(mocked, myfun, fun(Filename) -> ok end),
    ?_assertEqual(ok, get_config()),
    ?_assert(meck:validate(mocked)),
    meck:unload(mocked).
-endif.

Compiling and running tests:

1> c(example, [{d, 'TEST'}]).
example.erl:19: Warning: variable 'Filename' is unused
example.erl:20: Warning: a term is constructed, but never used
example.erl:21: Warning: a term is constructed, but never used
{ok,example}
12> example:test().           
undefined
*** test module not found ***
::ok

=======================================================
  Failed: 0.  Skipped: 0.  Passed: 0.
One or more tests were cancelled.
error

However, if I comment the line meck:unload(mocked). then test passes successfully.

@eproxus
Copy link
Owner

eproxus commented Aug 3, 2012

Sorry for the late reply. The issue occurs because the trailing underscore (get_config_test_) tells EUnit that the function is a test generator, not a test. EUnit then expects the function to return a list of tests instead.

@eproxus eproxus closed this as completed Aug 3, 2012
@ostinelli
Copy link
Author

indeed, it's a generator. i guess then meck has to be used within a test. i haven't find anything clarifying that in docs.

thank you,

r.

@eproxus
Copy link
Owner

eproxus commented Aug 11, 2012

Meck is not tied to a specific test library or framework. It just has a functional API that you can use in any code, really.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants