Prevent eunit from timing out when running Triq tests

809 views Asked by At

How can I change the timeout for the eunit in rebar3 config?

My eunit runner is timing out when I run property-based Triq tests:

===> Verifying dependencies...
===> Compiling ierminer
===> Performing EUnit tests...

Pending:
  test_ec:ec_prop_test/0
    %% Unknown error: timeout
  undefined
    %% Unknown error: {blame,[3,1]}


Finished in ? seconds
3 tests, 0 failures, 3 cancelled
===> Error running tests

Here is my property specification:

-module(ec_property).
-include_lib("triq/include/triq.hrl").

prop_append() ->
    ?FORALL({Xs,Ys},{list(int()),list(int())},
            lists:reverse(Xs++Ys)
            ==
            lists:reverse(Ys) ++ lists:reverse(Xs)).

prop_valid_started() ->
        ?FORALL({Type, Items, Size},
        {oneof([left,right]), non_empty(list(any())), pos_integer()},
            element(1, ec:start(Type, Items, Size)) == ok).

and here is how I call it from my eunit test function:

ec_prop_test() -> ?assert(ec_property:check()).
1

There are 1 answers

0
Steve Vinoski On BEST ANSWER

Use a test generator function to specify a timeout longer than the default 5 seconds:

ec_prop_test_() ->
    {timeout, 30, ?_assert(ec_property:check())}.

Note the trailing underscore added to the function name—that's how you create a test generator. Note also the leading underscore on _assert, which is one way to create a test object.

Change the 30 in the example to whatever number of seconds you need.