[erlang-questions] Eunit testing after starting the application
Nathaniel Waisbrot
nathaniel@REDACTED
Thu May 31 17:37:12 CEST 2018
I don't have a good answer to your exact question, but I do have two tips: `application:ensure_all_started/1` asks Erlang to figure out how to start all the dependencies in the correct order and handles the case of an application already having been started.
And `application:set_env/4` will allow you to programmatically set the Erlang env variables without a config file.
> On May 31, 2018, at 11:24 AM, Code Wiget <codewiget95@REDACTED> wrote:
>
> Hey everyone,
>
> How do you go about EUnit testing that requires the whole application to be running before the test ?
>
> For example, my erlang application starts one pool of processes that connects to a database and another that connects to another server in our backend. To run any real tests, I’m going to need to have one or both of those systems up and running. The way that I’m doing is right now is below, and it is very cluge-y feeling:
>
> ok = application:start(compiler),
> ok = application:start(syntax_tools),
> ok = application:start(goldrush),
> ok = application:start(gproc),
> ok = application:start(gen_logger),
> ok = application:start(pooler),
> ok = application:start(quickrand),
> ok = application:start(re2),
> ok = application:start(lz4),
> ok = application:start(uuid),
> ok = application:start(semver),
> ok = application:start(snappy),
> ok = application:start(cqerl),
> ok = application:start(ecpool),
> ok = application:start(esockd),
> ok = application:start(lager_syslog),
> ok = application:start(lager),
>
>
> This system works because none of the above applications require any environment variables from a config file. So some of my other applications can’t run using this. Is there any way to have eunit run the test after starting the whole application?
>
> Thanks!
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180531/7ff142d5/attachment.htm>
More information about the erlang-questions
mailing list