[erlang-questions] Timeout control in EUnit

Richard Carlsson richardc@REDACTED
Thu Jun 4 18:12:17 CEST 2009


Koushik Narayanan wrote:
> How do we specify timeout for tests in eunit, 
> when the test module has more than one generator?

The timeout handling is currently a bit unpolished (not quite
flexible enough), but what you can do is this:

 slow_test_() ->
         {timeout, 60,
          fun() ->
                 timer:sleep(10000)
          end}.

The thing to keep in mind is that each {timeout, Seconds, Tests} sets a
maximum total time for finishing all of Tests.

Also:

> -include_lib("/usr/lib/erlang/lib/eunit-2.1/include/eunit.hrl").

Note that the whole purpose of include_lib(...) is so that you do
*not* have to write the whole path including version numbers. For
portable code, you should write:

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

and then set up your build environment so that the eunit directory
is found automatically during compilation.

    /Richard


More information about the erlang-questions mailing list