Re: Properly testing an OTP application after initialization
"Paulo F. Oliveira" <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CA+dV7cQ=TwN835eb1VTFQkJUdraZq0mCBWNZ5Me93ku5onbhyw@mail.gmail.com> |
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.