<div dir="ltr">I don't have an explanation for the application sometimes failing to find the config file, but I can say that when I tried to use EUnit for anything slightly more complicated than the simplest of tests, it turned into a frustrating experience. Instead, I changed my tests to Common Test, which may be a bit like killing a fly with a baseball bat, but it sure does the job. And you can ramp up slowly with CT; I'm just using the _data directory to hold data files and the init_per_suite/end_per_suite hooks to set up and tear down. The best part is I didn't have to change the tests themselves, other than to receive a Config argument.<div><br></div><div>Short answer: use Common Test.</div><div><br></div><div>n</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 23, 2014 at 11:06 PM, linbo liao <span dir="ltr"><<a href="mailto:llbgurs@gmail.com" target="_blank">llbgurs@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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> </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" target="_blank">Fixtures</a><span> </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>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>