EUnit is used for unit testing. Unit tests reside in the module they are testing and test the module in isolation. The basic test skeleton should be encapsulated in a TEST block.
fun setup/0, fun cleanup/1,
[ fun my_test/1, ... ]
% Setup and Cleanup
setup() -> io:format(user,"setup",), ...
cleanup(Args_from_setup_return) -> ...
- All tests can then be executed via
- A single module can be tested via
rebar3 eunit --module=MODULE_NAME
- Log output is consumed; use
io:format/3for debugging purposes
System test suite tests a certain aspect of the system and can be either a single data center or a multi-datacenter suite.
A suite should be name
To execute system tests, execute one of the following commands
make singledc SUITE=...
make multidc SUITE=...
Every system test should have its own bucket namespace defined at the top of the suite. Unique bucket namespaces ensure that test suites do not interfere with each other. The convention is filename with SUITE replaced by bucket. E.g., the bucket for
antidote_SUITE.erlshould be defined as
and the macro should be used once at the start of a test case, defining the bucket to be used for that test case. If a unique bucket per test case is needed (e.g. for parallel tests), then
can be used instead.
System tests which use multiple data centers are located in the test/multidc folder. The fixed test setup is as follows:
- 3 interconnected Data center
- Data center one has two physical nodes
make reltesttests the antidote release executable.
To log messages in a test suite, use the function
ct:log. If a message should be visibile in the printed log (e.g. in travis), then
ct:printcan be used.
All other logging messages (
logger) end up in the
ctHTML summary, see the generated
logs/index.htmlfile and navigate to the test cases you want to see the logs of.
There are multiple help functions already implemented for common functionality in the
test/utilsfolder. They are separated by functionality into the following files:
- Functions to manipulate antidote data types
- Riak cluster management. Useful for multi-dc tests.
- Time-based helper functions
- Test initialization and other helper functions which do not fit into the other categories