简体   繁体   English

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

[英]Prevent eunit from timing out when running Triq tests

How can I change the timeout for the eunit in rebar3 config? 如何在rebar3配置中更改eunit的超时?

My eunit runner is timing out when I run property-based Triq tests: 当我运行基于属性的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

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: 以下是我从我的eunit测试函数中调用它的方法:

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

Use a test generator function to specify a timeout longer than the default 5 seconds: 使用测试生成器函数指定超过默认值5秒的超时:

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. 还要注意_assert上的前导下划线,这是创建测试对象的一种方法。

Change the 30 in the example to whatever number of seconds you need. 将示例中的30更改为您需要的秒数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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