EUnit and Servers
Fred Hebert (MononcQc)
mononcqc@REDACTED
Sun Sep 27 18:04:09 CEST 2009
I have used EUnit before, but rarely did server testing with it. I decided
to give it a hand with some toy code of mine, but I'm getting errors I'm not
able to understand the cause of. I'm not willing to blame the tools (eunit)
before the tool (me), so I'm asking for help here:
Here's a paste of the test module:
http://paste.lisp.org/display/87803
I don't think it's really important to understand the intricacies of the
functions from box or air, but you can get a quick description at the bottom
of this post if you want.
When running the tests, I get the result:
20> c("tests/box_tests").
{ok,box_tests}
21> eunit:test(box).
box_tests: status_test_...*failed*
::exit:{noproc,{gen_server,call,[box,get_status]}}
in function gen_server:call/2
in call from box_tests:'-status_test_/0-fun-2-'/0
in call from box_tests:'-status_test_/0-fun-4-'/0
=======================================================
Failed: 1. Skipped: 0. Passed: 5.
So it seems like the box:start_link/0 function for this specific test
failed somehow.
What happens when I just add a second version of add_test_/0 and name it
add2_test_/0 is that now, add_test_/0 *AND* status_test_/0 now both fail,
but add2_test_/0 won't fail.
I'm not quite sure why this happens; all test setups are pretty much the
same, but some work and others won't. I have obviously done something wrong
but can't find what. Anyone got an idea? (I'm guessing race conditions on
start_link/1s and stop/0s, but I'm not quite sure).
Thanks in advance.
---------------------------------------
description of the functions:
air defines an #air{} record with quantities of oxygen, co2, n2 and argon in
it. air provides functions to work on them: total of gases, the ratio of
each of them, a map and mergewith function (applying a function on each
element of the record, returning a new one), etc.
box is a server holding a quantity of gas. get_air/1 will subtract a
quantity of air from the box. add_air/1 will add air (as the name says it)
and get_status/0 shows the quantity of each gas in the box. init/1 is called
all the time because it will create a new #air{} record with proportions
similar to what we've got in the atmosphere.
More information about the erlang-questions
mailing list