[erlang-questions] False negatives in EUnit
Per Melin
per.melin@REDACTED
Sun Apr 3 18:40:57 CEST 2011
Below are five EUnit tests that all pass without so much as a warning.
If you're an experienced EUnit user you will tell me that they are all
illegal tests, which they are. But is it obvious? If you are less
experienced with EUnit, or maybe just a little clumsy, or go too fast
when you refactor a test you could write something like this, and you
may never know. All it takes is that you fail to spot the missing or
extra underscore.
To silently hide errors is the last thing I want in a testing
framework. Is there a way to fix this?
a_test() ->
?_assertEqual(1, 2).
b_test() ->
?_test(?assertEqual(1, 2)).
c_test_() ->
?_test(fun() -> 1 = 2 end).
d_test_() ->
[fun() -> ?_assertEqual(1, 2) end].
e_test() ->
{setup,
fun() -> ok end,
[?_assertEqual(1, 2)]}.
======================== EUnit ========================
module 'oops'
oops:12: c_test_...ok
oops: a_test...ok
oops: b_test...ok
oops: d_test_...ok
oops: e_test...ok
[done in 0.017 s]
=======================================================
All 5 tests passed.
More information about the erlang-questions
mailing list