Module prefixes and eunit command

Tim Watson watson.timothy at
Sun Jul 3 15:45:29 EDT 2011

> What's the rule that rebar uses for detecting tests for an app?

The rebar_eunit module first compiles sources in the main (i.e., src)
and test directories, and then copies the beam files and sources over
to a working directory (named .eunit) and cover compiles them. Prior
to cover compilation, rebar_eunit collates a list of all the beam
files in the .eunit directory but removes any modules matching
*_tests.beam so that (a) they aren't included in the coverage reports
and (b) eunit doesn't try to run them twice.

Finally, rebar_eunit calls eunit:test/2 with a list of all the
production module names. This (eunit) function runs any tests in the
production module(s), but also scans the code path for modules whose
name matches the production module and is also suffixed with "_tests"
- this is how *eunit* detects your test modules. Rebar doesn't
explicitly list them.

To achieve what you want, you may be able to use the global "suite"
variable in conjunction with the `rebar eunit` command. When provided,
this causes rebar_eunit to call eunit:test/1 with the name of the
suite, which can also be a comma separated list of module names. It's
hardly ideal, but does provide a work around.

More information about the rebar mailing list