[erlang-questions] Eunit question...

Gianfranco Alongi <>
Sun Nov 6 22:12:59 CET 2011


You put the timeout in the Tests.

-module(demo_tests).
-include_lib("eunit/include/eunit.hrl").
timeout_setup_test_() ->
     {setup,
      fun() -> ok end,
      fun(_) -> ok end,
      {timeout,20,
       fun() -> ok = demo:a() end}}.


-module(demo_tests).
-include_lib("eunit/include/eunit.hrl").
timeout_setup_test_() ->
     {setup,
      fun() -> ok end,
      fun(_) -> ok end,
      {timeout,20,
       fun() -> ok = demo:a() end}}.


erlc *.erl
erl
eunit:test(demo).




On Sun, Nov 6, 2011 at 9:58 PM, Bryan Hughes <> wrote:
> Hi Everyone,
>
> Hoping someone might be able to help me understand how to set up a unit test
> with EUnit which needs both timeout and fixture setup/cleanup.  I find the
> documentation a bit challenging on this particular aspec.
>
> For example, according to the documentation for using the fixture pattern:
>
> {setup, Setup, Tests | Instantiator}
> {setup, Setup, Cleanup, Tests | Instantiator}
> {setup, Where, Setup, Tests | Instantiator}
> {setup, Where, Setup, Cleanup, Tests | Instantiator}
>
>
> So my normal tests look like:
>
> my_test_() ->
>     {setup,
>      fun setup/0,
>      fun cleanup/1,
>      ?_test(begin
>                 ...
>             end)}.
>
> For using adjusting the timeout, the documentation describes this pattern:
>
> {timeout, Time::number(), Tests}
>
> I have not been able to figure out how to craft my test.  Unfortunately my
> variations just fail, or just quietly end without running any of the
> remaining tests for the module.
>
>
> Thanks!!!
>
> Cheers,
> Bryan
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>



More information about the erlang-questions mailing list