简体   繁体   中英

Prevent eunit from timing out when running Triq tests

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM