Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
meck
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Roberto Ostinelli  
View profile  
 More options Jul 22 2012, 10:15 pm
From: Roberto Ostinelli <robe...@widetag.com>
Date: Sun, 22 Jul 2012 19:15:42 -0700
Local: Sun, Jul 22 2012 10:15 pm
Subject: [erlang-questions] meck

dear all,

i'm trying to use the meck framework (https://github.com/eproxus/meck) and
i can't seem to find a way to test that a function gets called with the
appropriate values.

for instance:

%%%%%%%%%%%%%%%%%%%%

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

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

-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)).
-endif.

%%%%%%%%%%%%%%%%%%%%

i'd like to test that mocked:myfun/1 gets called with "test.config" as
parameter.

is this possible?

r.

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Slava Yurin  
View profile  
 More options Jul 23 2012, 12:37 am
From: Slava Yurin <Yuri...@yandex.ru>
Date: Mon, 23 Jul 2012 11:37:05 +0700
Local: Mon, Jul 23 2012 12:37 am
Subject: Re: [erlang-questions] meck

From meck readme.md:
 
my_test() ->
    meck:new(my_library_module),
    meck:expect(my_library_module, fib, fun(8) -> 21 end),
    ?assertEqual(21, code_under_test:run(fib, 8)), % Uses my_library_module
    ?assert(meck:validate(my_library_module)),
    meck:unload(my_library_module).
 
23.07.2012, 09:15, "Roberto Ostinelli" <roberto@widetag.com>:
dear all,
i'm trying to use the meck framework (https://github.com/eproxus/meck) and i can't seem to find a way to test that a function gets called with the appropriate values.
for instance:
%%%%%%%%%%%%%%%%%%%%
-module(example).
-compile(export_all).
get_config() ->
mocked:myfun("test.config").
-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)).
-endif.
%%%%%%%%%%%%%%%%%%%%
i'd like to test that mocked:myfun/1 gets called with "test.config" as parameter.
is this possible?
r.

_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Motiejus Jakštys  
View profile  
 More options Jul 23 2012, 4:07 am
From: Motiejus Jakštys <desired....@gmail.com>
Date: Mon, 23 Jul 2012 10:07:59 +0200
Local: Mon, Jul 23 2012 4:07 am
Subject: Re: [erlang-questions] meck

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
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roberto Ostinelli  
View profile  
 More options Jul 25 2012, 1:30 am
From: Roberto Ostinelli <robe...@widetag.com>
Date: Tue, 24 Jul 2012 22:30:55 -0700
Local: Wed, Jul 25 2012 1:30 am
Subject: Re: [erlang-questions] meck

> 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.

can't i use this in generators?

the reason why i didn't include unload is because of this:
https://github.com/eproxus/meck/issues/72

r.

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Fwd: meck" by Motiejus Jakštys
Motiejus Jakštys  
View profile  
 More options Jul 27 2012, 3:32 am
From: Motiejus Jakštys <desired....@gmail.com>
Date: Fri, 27 Jul 2012 10:32:18 +0300
Local: Fri, Jul 27 2012 3:32 am
Subject: [erlang-questions] Fwd: meck
Forwarding to list.

---------- Forwarded message ----------
From: Motiejus Jakštys <desired....@gmail.com>
Date: Wed, Jul 25, 2012 at 9:31 AM
Subject: Re: [erlang-questions] meck
To: Roberto Ostinelli <robe...@widetag.com>

On Wed, Jul 25, 2012 at 7:30 AM, Roberto Ostinelli <robe...@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

--
Motiejus Jakštys
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »