_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Hi,
you are mixing eunit generators with simple test cases. Did you mean this?
get_config_test() ->
meck:new(mocked),
meck:expect(mocked, myfun, fun(Filename) -> ok end),
?assertEqual(ok, get_config()),
?assert(meck:called(mocked, myfun, ["test.config"])),
meck:unload(mocked).
Normally, you should split meck:new and meck:unload to separate
setup/cleanup functions. Because if a test fails and the module is not
cleaned, it might unexpectedly do ill for your other test cases.
--
Motiejus Jakštys
Hi,
you are mixing eunit generators with simple test cases. Did you mean this?
get_config_test() ->
meck:new(mocked),?assertEqual(ok, get_config()),
meck:expect(mocked, myfun, fun(Filename) -> ok end),
?assert(meck:called(mocked, myfun, ["test.config"])),
meck:unload(mocked).
Normally, you should split meck:new and meck:unload to separate
setup/cleanup functions. Because if a test fails and the module is not
cleaned, it might unexpectedly do ill for your other test cases.
---------- Forwarded message ----------
From: Motiejus Jakštys <desir...@gmail.com>
Date: Wed, Jul 25, 2012 at 9:31 AM
Subject: Re: [erlang-questions] meck
To: Roberto Ostinelli <rob...@widetag.com>
On Wed, Jul 25, 2012 at 7:30 AM, Roberto Ostinelli <rob...@widetag.com> wrote:
>
> can't i use this in generators?
You can, but another way. Generator must return a set of test cases.
For instance:
arith_test_() ->
[
?_assertEqual(4, 2*2),
?_assertEqual(0, 1*0)
].
From eunit manual[1]:
A function with a name ending in ..._test_() (note the final
underscore) is recognized by EUnit as a test generator function. Test
generators return a representation of a set of tests to be executed by
EUnit.
Stick with the simple test case instead (which ends with test()).
> the reason why i didn't include unload is because of this:
> https://github.com/eproxus/meck/issues/72
As said, try simple test case first.
[1]: http://www.erlang.org/doc/apps/eunit/chapter.html#EUnit_macros
--
Motiejus Jakštys