在运行Triq测试时,防止eunit超时

时间:2016-04-05 19:02:53

标签: erlang rebar eunit triq

如何在rebar3配置中更改eunit的超时?

当我运行基于属性的Triq测试时,我的eunit runner正在超时:

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

这是我的属性规范:

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

以下是我从我的eunit测试函数中调用它的方法:

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

1 个答案:

答案 0 :(得分:3)

使用test generator function指定超过默认5秒的超时时间:

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

请注意添加到函数名称的尾随下划线 - 这就是您创建测试生成器的方式。另请注意_assert上的前导下划线,这是创建测试对象的一种方法。

将示例中的30更改为您需要的秒数。

相关问题