[erlang-questions] EUnit and Servers
Richard Carlsson
richardc@REDACTED
Sun Sep 27 19:16:11 CEST 2009
The first of your test generators creates test objects as it should:
init_test_() ->
[?_assert(close_enough(air:new(21, 0.04, 78, 0.9),
get_val(box:init(100)))),
?_assert(close_enough(air:new(0.21, 0.0004, 0.78, 0.009),
get_val(box:init(1)))),
?_assertError(function_clause, box:init(-1))].
(i.e., using macro calls beginning with ?_...).
However, the rest of the generators are using the macro forms
that will execute immediately, when the generator itself runs:
add_test_() ->
{setup, fun() -> box:start_link(0) end, fun(_) -> box:stop() end,
fun() ->
{inorder,
[?assertEqual(ok, box:add_air(get_val(box:init(100)))),
?assert(close_enough(box:get_air(200),
get_val(box:init(100))))]}
end}.
Just change those ?assert... to ?_assert... and try again.
This is also why the total count in the report was weird (just 6?):
=======================================================
Failed: 1. Skipped: 0. Passed: 5.
I know that EUnit is currently not good at telling you when your
generators are doing things that you probably didn't intend. I'll try
to improve that.
/Richard
More information about the erlang-questions
mailing list