Module etest

This modules provides a basic testing framework for AtomVM Erlang libraries.

Function Index

assert_equals/2
assert_exception/1
assert_exception/2
assert_exception/3
assert_match/2
assert_true/1
flush_msg_queue/0Use optionally to flush messages in test cases that run in a single test module.
test/1 Test a sequence of test modules.

Function Details

assert_equals/2


assert_equals(X::term(), Y::term()) -> ok | fail

X: a term
Y: a term

returns: ok if X and Y are equal; fail otherwise.

assert_exception/1


assert_exception(F::function()) -> ok | fail

F: a function to evaluate

returns: ok if evaluating F results in Error being raised; fail, otherwise

assert_exception/2


assert_exception(F::function(), Class::throw | error | exit) -> ok | fail

F: a function to evaluate
Class: expected exception class

returns: ok if evaluating F results in an exception of class Class being raised; fail, otherwise

assert_exception/3


assert_exception(F::function(), Class::throw | error | exit, E::any()) -> ok | fail

F: a function to evaluate
Class: expected exception class
E: expected exception value

returns: ok if evaluating F results in an exception of class Class and of value E being raised; fail, otherwise

assert_match/2


assert_match(X::term(), Y::term()) -> ok | fail

X: a term
Y: a term

returns: ok if X and Y unify; fail otherwise.

assert_true/1


assert_true(X::boolean()) -> ok | fail

X: a term

returns: ok if X is true; fail otherwise.

flush_msg_queue/0


flush_msg_queue() -> ok

returns: ok after flushing all messages in the process message queue

Use optionally to flush messages in test cases that run in a single test module

test/1


test(Tests::[module()]) -> ok | fail

Tests: a list of test modules

returns: ok if all of the tests pass, or the atom fail, if any of the tests failed.

Test a sequence of test modules.

This function will execute the test/0 function for each module provided in the input list of test modules. If all of the tests return the atom ok, then this function returns ok. If any of the test modules return a value other than ok, then this function returns the atom fail.