problem on timeout setting in eunit tests

metal zong metalzong@REDACTED
Fri Sep 17 09:51:50 CEST 2010


Hello,

Seems timeout mechanism of eunit can not work properly with test set which
contains more than one test and also can not work with fixture properly.

Please see following code for more information.


-module(test).

-export([run/0]).

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

setup() ->
    ?debugMsg("setup ..."),
    ok.

teardown(S) ->
    ?debugFmt("teardown ... ~p~n", [S]),
    ok.

test() ->
    timer:sleep(1000),
    ?debugMsg("test ..."),
    ok.

test0() ->
    timer:sleep(6000),
    ?debugMsg("test0 ..."),
    ok.

test1(P) ->
    timer:sleep(1000),
    ?debugFmt("test1 ... ~p~n", [P]),
    ok.

test2(P) ->
    timer:sleep(6000),
    ?debugFmt("test2 ... ~p~n", [P]),
    ok.

run() ->
    %% {timeout, 60, [fun test0/0]}.                                %% ok
    %% {timeout, 60, [fun test/0, fun test0/0]}.                    %%
timeout

    %% {timeout, 60, {with, setup(), [fun test2/1]}}.               %% ok
    %% {timeout, 60, {with, setup(), [fun test1/1, fun test2/1]}}.  %%
timeout

    %% {timeout, 60, {setup, fun setup/0, fun teardown/1, {with, [fun
test2/1]}}}. %% timeout
    %% {timeout, 60, {setup, fun setup/0, fun teardown/1, {with, [fun
test1/1, fun test2/1]}}}. %%timeout


More information about the erlang-questions mailing list