[erlang-questions] How to start application before all eunit cases

linbo liao <>
Mon Nov 24 08:06:16 CET 2014


My Erlang project managed by rebar, it divides to different module.

-pro
  |-- rel
  |-- src
     |--- module1
     |--- module2
  |-- test
     |--- module1_tests.erl
     |--- module2_tests.erl

and for each module*_tests.erl, Use Eunit Fixtures
<http://www.erlang.org/doc/apps/eunit/chapter.html#Fixtures> to setup
environment. For example,

module1_test_() ->
    {setup,
        fun setup/0,
        fun clean_up/1,
        fun (SetupData) ->
            [
                test_function(SetupData)
            ]
    end}.

setup() ->
    pro:start(),
    ok.

clean_up(_) ->
    pro:stop().

And Makefile is:

test:
    ERL_AFLAGS="-config rel/pro/etc/app.config"  $(REBAR)  compile
eunit skip_deps=true

Here I encounter a problem, since I have many test module in test/, each
test module will start and stop application for whole executing flow.
Sometimes start application will be failed, told not find app.config
configure file, not sure why.

So I think is there a way to start application before all test module?

Thanks,

Linbo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141124/1d86c26a/attachment.html>


More information about the erlang-questions mailing list