Re: Properly testing an OTP application after initialization
Max Lapshin <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAMxVRxCPxS_55b+U030M8g82Dspi=fASYvUN_OZ+8YgN0g21dg@mail.gmail.com> |
I have tried EUnit very long ago and found it too error prone, when I understood that simply forgetting to put _ can lead to changing "list of tests" to a "test that successfully returns a list". And I don't see anything good in having 2000 lines of tests in the same module which is only 300-400. On Mon, Sep 14, 2020 at 2:25 PM Paulo F. Oliveira <[email protected]> wrote: > > On Mon, 14 Sep 2020 at 06:07, Max Lapshin <[email protected]> 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.