EUnit
To run all EUnit test suites:
Rebar3 will compile all project modules with the macros {d, TEST, true} and {d, EUNIT, true} defined so you can safely hide your test code within -ifdef(TEST). or -ifdef(EUNIT). sections. It will also automatically compile any source files in your application’s test directory, if present. By default, Rebar3 runs tests by calling eunit:test([{application, App}]) for each application in your project.
The eunit command runs as the test profile, by default. See Profiles for details.
For available options and their usage see Commands or:
Test Selection
The following flags can be provided standalone or combined.
Apps
To run tests for specific apps only:
The format is a comma separated list of application names.
Alias: --app.
Modules
To run tests for specific modules only:
The format is a comma separated list of module names.
Alias: --suite.
Test Cases
To run specific test cases only:
The format is a comma separated list of test functions.
Generators
To run specific test case generators only:
The format is a comma separated list of test functions.
Files
To run tests for specific files only:
The format is a comma separated list of file paths.
Directories
To run tests for specific directories only:
The format is a comma separated list of directory paths.
Test Function Format
The format to select specific test functions is a comma separated list of Module:Func specifications. Multiple functions in the same module can be selected by separating them with a plus + sign, e.g. Module:Func1+Func2 (alternatively they can be separated with a semicolon ;).
Configuration Options
The following configuration options can be set in rebar.config.
eunit_tests
You can change the default tests eunit:test/1 is called with when running rebar3 eunit (instead of the default which are all tests in all applications).
The configuration must be a list with EUnit test representations, as documented here. Rebar3 will do its best to ensure any modules specified in tests are compiled and made available on the code path.
Examples:
eunit_opts
The default EUnit options can be configured, as documented here.
Interesting undocumented options are:
-
no_ttycompletely disables the default EUnit reporter output -
{report, {Module, Args}}runs a custom EUnit reporter (the functionality that prints results to the shell). The reporter module needs the following callbacks implemented:
no_tty and report can be combined to replace the EUnit reporter with a custom one: