Fwd: problem on timeout setting in eunit tests

metal zong metalzong@REDACTED
Fri Sep 17 09:57:31 CEST 2010


erlang: erlang-r13b04
eunit: eunit-2.1.5 and latest code in svn

---------- Forwarded message ----------
From: metal zong <metalzong@REDACTED>
Date: Fri, Sep 17, 2010 at 3:51 PM
Subject: problem on timeout setting in eunit tests
To: erlang-questions@REDACTED


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