Jan
29th
Thu
29th
Erlang/Eunit Test Structuring Idea
Nifty post from Adam Lindberg on the Erlang-Questions mailing list, about how he structures his eunit tests:
In myapp/src/foo.erl I put a small header file inclusion:
-ifdef(TEST).
-include("foo_test.hrl").
-endif.
And myapp/test/foo_tests.hrl looks like this:
-include_lib("eunit/include/eunit.hrl").
foo_test_() ->
[?_assertEqual(ok, public_function())].
bar_test_() ->
[?_assertEqual(ok, private_function())].
With the right compile options, you get tests only built into the code during dev, and you get to keep your tests in a separate file (but still have full access to the internal functions, which I find absolutely necessary).
-Dan M

