<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,"Liberation Sans","DejaVu Sans",sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:17.8048px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background:none repeat scroll 0% 0% rgb(255,255,255)">My Erlang project managed by rebar, it divides to different module.</p><pre style="margin:0px 0px 10px;padding:5px;border:0px none;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:17.8048px;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;background:none repeat scroll 0% 0% rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,serif;white-space:inherit;background:none repeat scroll 0% 0% rgb(238,238,238)">-pro
  |-- rel
  |-- src<br>     |--- module1<br>     |--- module2<br>  |-- test
     |--- module1_tests.erl
     |--- module2_tests.erl
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,"Liberation Sans","DejaVu Sans",sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:17.8048px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background:none repeat scroll 0% 0% rgb(255,255,255)">and for each module*_tests.erl, Use Eunit<span class=""> </span><a href="http://www.erlang.org/doc/apps/eunit/chapter.html#Fixtures" rel="nofollow" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;color:rgb(74,107,130);text-decoration:none;background:none repeat scroll 0% 0% transparent">Fixtures</a><span class=""> </span>to setup environment. For example,</p><pre style="margin:0px 0px 10px;padding:5px;border:0px none;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:17.8048px;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;background:none repeat scroll 0% 0% rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,serif;white-space:inherit;background:none repeat scroll 0% 0% rgb(238,238,238)">module1_test_() ->
    {setup,
        fun setup/0,
        fun clean_up/1,
        fun (SetupData) ->
            [
                test_function(SetupData)
            ]
    end}.

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

clean_up(_) ->
    pro:stop().
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,"Liberation Sans","DejaVu Sans",sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:17.8048px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background:none repeat scroll 0% 0% rgb(255,255,255)">And Makefile is:</p><pre style="margin:0px 0px 10px;padding:5px;border:0px none;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:17.8048px;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;background:none repeat scroll 0% 0% rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,serif;white-space:inherit;background:none repeat scroll 0% 0% rgb(238,238,238)">test:
    ERL_AFLAGS="-config rel/pro/etc/app.config"  $(REBAR)  compile eunit skip_deps=true 
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,"Liberation Sans","DejaVu Sans",sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:17.8048px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background:none repeat scroll 0% 0% rgb(255,255,255)">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.</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,"Liberation Sans","DejaVu Sans",sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:17.8048px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background:none repeat scroll 0% 0% rgb(255,255,255)">So I think is there a way to start application before all test module?</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,"Liberation Sans","DejaVu Sans",sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:17.8048px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background:none repeat scroll 0% 0% rgb(255,255,255)">Thanks,</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,"Liberation Sans","DejaVu Sans",sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:17.8048px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background:none repeat scroll 0% 0% rgb(255,255,255)">Linbo<br></p></div>