My Erlang project managed by rebar, it divides to different module.
-pro
|-- rel
|-- src
|-- test
|--- module1_tests.erl
|--- module2_tests.erl
and for each module*_tests.erl, Use Eunit 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?
From Erlang docs -config flag you used (ERL_AFLAGS="-config rel/pro/etc/app.config") has to be ERL_AFLAGS="-config app"