Properly testing an OTP application after initialization

Paulo F. Oliveira paulo.ferraz.oliveira@REDACTED
Mon Sep 14 13:24:29 CEST 2020


On Mon, 14 Sep 2020 at 06:07, Max Lapshin <max.lapshin@REDACTED> wrote:

> I do not understand what fixtures are for.
>

It's explained in http://erlang.org/doc/apps/eunit/chapter.html#Fixtures: A
"fixture" is some state that is necessary for a particular set of tests to
run. EUnit's support for fixtures makes it easy to set up such state
locally for a test set, and automatically tear it down again when the test
set is finished, regardless of the outcome (success, failures, timeouts,
etc.).


> We test our flussonic in this manner:
>
> init_per_suite(Config) ->
>   application:ensure_all_started(flussonic)
>   Config.
>
> ...
>
> end_per_suite(Config) ->
>   application:stop(flussonic),
>   Config.
>

This is probably because you're using Common Test, and not EUnit.

EUnit can be easily integrated into a module (without having to have a
separate test/ folder and other "boilerplate" stuff), via -ifdef(TEST).
fun_test() ..., and fixtures just make it that easy to keep all the code in
the same place.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200914/19dec2da/attachment.htm>


More information about the erlang-questions mailing list