As Pascal wrote, unfortunately EUnit doesn't have test case autoregistration.
On the other hand, if you write the test functions inline and use "test titles", you can obtain the equivalent of autoregistration:
fixture_test_() ->
{
setup,
fun test_setup/0,
fun test_teardown/1,
[
% Simplest possible. One single assertion.
% Note the presence of the "_" prefix.
{"description of test case 1",
?_assert(true)
},
% Slighly more complicated: multiple assertions inside a list.
% Note the presence of the "_" prefix.
{"description of test case 2", [
?_assert(true),
?_assert(true),
?_assert(true)
]},
% Even more complicated, when you really need a function.
% Note the absence of the "_" prefix.
{"description of test case 3",
fun() ->
X = f1(),
Y = f2(X),
?assertEqual(foo, Y)
end}
]
}.
When running with verbose mode on:
$ rebar eunit suite=pizza
==> mcs (eunit)
======================== EUnit ========================
module 'pizza'
module 'pizza_tests'
pizza_tests:29: fixture_test_ (description of test case 1)...ok
description of test case 2
pizza_tests:34: fixture_test_...ok
pizza_tests:35: fixture_test_...ok
pizza_tests:36: fixture_test_...ok
[done in 0.009 s]
pizza_tests: fixture_test_ (description of test case 3)...ok
[done in 0.015 s]
[done in 0.015 s]
=======================================================
All 5 tests passed.