eunit_sugar

Helpers and sugars for eunit tests


License
Apache-2.0

Documentation

eunit_sugar

  • Builds on eunit's fixtures to make implementing test suites easier by reducing boilerplate code.
  • Designed to work alongside existing eunit tests.

API

fixture

fixture(Module) -> FixtureTuple
fixture(Module, Prefix) -> FixtureTuple
fixture(Module, Setup, Teardown) -> FixtureTuple
fixture(Module, Prefix, Setup, Teardown) -> FixtureTuple

Types:

  • Module = atom()
  • Prefix = atom() | string()
  • Setup = atom()
  • Teardown = atom()
  • FixtureTuple = tuple()

Declares a group of functions from Module as test functions that will be run as eunit test functions.
When Prefix is present, only functions whose name match Prefix with an arity of 0 will be selected for inclusion. When Prefix is not present, every function in the module with an arity of 0 (with a few exceptions) will be selected.
Setup and Teardown are functions that will be run before and after each test function in the group.

parameterized_fixture

parameterized_fixture(Module, Setup, Teardown) -> FixtureTuple
parameterized_fixture(Module, Prefix, Setup, Teardown) -> FixtureTuple

Types:

  • Module = atom()
  • Prefix = atom() | string()
  • Setup = atom()
  • Teardown = atom()
  • FixtureTuple = tuple()

Declares a group of functions from Module as test functions that will be run as eunit test functions.
When Prefix is present, only functions whose name match Prefix with an arity of 1 will be selected for inclusion. When Prefix is not present, every function in the module with an arity of 1 (with a few exceptions) will be selected.
Setup and Teardown are functions that will be run before and after each test function in the group.
parameterized_fixture differs from fixture in that Setup will be run before each test function and the output will be passed to the test function as an argument.

Resources: