I'm going through the EUnit chapter in Learn You Some Erlang and one thing I am noticing from all the code samples is the test functions are never declared in -export()
clauses.
Why is EUnit able to pick these test functions up?
The simplest way to use EUnit in an Erlang module is to add the following line at the beginning of the module (after the
-module
declaration, but before any function definitions):-include_lib("eunit/include/eunit.hrl").
This will have the following effect:
Creates an exported function
test()
(unless testing is turned off, and the module does not already contain a test() function), that can be used to run all the unit tests defined in the moduleCauses all functions whose names match
..._test()
or..._test_()
to be automatically exported from the module (unless testing is turned off, or theEUNIT_NOAUTO
macro is defined)