2009-12-04 89 views
1

我想运行所有单元测试使用eunit内的文件夹,但它似乎像超时总是重置为5秒。Eunit超时不起作用

例如

模块:

-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, "."}}。有人有线索吗?

回答

5

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

我会写这样的测试:

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

(下划线加入到创建一个测试表达式,而不是测试本身,这一切都在eunit manual我不认为这是可以指定超时。以任何其他方式在测试中)。