Eunit 超时不起作用

发布于 2024-08-13 02:27:41 字数 780 浏览 3 评论 0 原文

我正在尝试使用文件夹内的 eunit 运行所有单元测试,但似乎超时总是重置为 5 秒。

eg

模块:

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

main_test() ->
    % sleep for 10 seconds
    ?assertEqual(true, begin timer:sleep(10000), true end).

命令行:

Eshell V5.7.3  (abort with ^G)
1> c(example).
{ok,example}
2> eunit:test({timeout, 15, example}).
  Test passed.
ok
3> eunit:test({timeout, 15, {dir, "."}}).
example: main_test (module 'example')...*timed out*
undefined
=======================================================
  Failed: 0.  Skipped: 0.  Passed: 0.
One or more tests were cancelled.
error

如您所见,运行 {timeout, 15, example} 有效,但 {timeout, 15, {dir, "." }}。有人知道吗?

I am trying to run all unit tests using eunit inside a folder but it seems like timeout always reset to 5 seconds.

e.g.

Module:

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

main_test() ->
    % sleep for 10 seconds
    ?assertEqual(true, begin timer:sleep(10000), true end).

Command line:

Eshell V5.7.3  (abort with ^G)
1> c(example).
{ok,example}
2> eunit:test({timeout, 15, example}).
  Test passed.
ok
3> eunit:test({timeout, 15, {dir, "."}}).
example: main_test (module 'example')...*timed out*
undefined
=======================================================
  Failed: 0.  Skipped: 0.  Passed: 0.
One or more tests were cancelled.
error

As you can see, running {timeout, 15, example} works but not {timeout, 15, {dir, "."}}. Does anyone have a clue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十级心震 2024-08-20 02:27:41

对我来说,这是有道理的:整个目录的超时可能与各个测试的超时无关。

我会这样编写测试:(

main_test_() ->
    % sleep for 10 seconds
    {timeout, 15, ?_assertEqual(true, begin timer:sleep(10000), true end)}.

添加下划线以创建测试表达式而不是测试本身;它全部位于 eunit 手册。我认为不可能以任何其他方式在测试本身中指定超时。)

To me that makes sense: the timeout for an entire directory is probably not related to the timeouts for the individual tests.

I would write the test like this:

main_test_() ->
    % sleep for 10 seconds
    {timeout, 15, ?_assertEqual(true, begin timer:sleep(10000), true end)}.

(Underscores added to create a test expression instead of the test itself; it's all in the eunit manual. I don't think it's possible to specify a timeout in the test itself in any other way.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文