[erlang-questions] Eunit testing after starting the application

Code Wiget codewiget95@REDACTED
Thu May 31 19:02:13 CEST 2018


I found this:
ERL_AFLAGS="-config etc/server.config" rebar3 eunit

This will set the config file to etc/server.config before compiling and running the eunit testing.

So in combination with ensure_all_started, then we can start the code necessary to run without the common test framework. This gets around the need to export functions for the common test framework so that we can test the internal functions.

On May 31, 2018, 12:52 PM -0400, Code Wiget <codewiget95@REDACTED>, wrote:
> Nathaniel,
>
> Thank you - ensure_all_started is going to save me dozens of lines of code in other locations =).
>
> Gleb,
>
> Are you suggesting not doing eunit testing and just running with common tests and using init_per_testcase ? I get that EUnit is easy, but for an application that is already built, when we are trying to test system functionality, maybe it is better to just go full on with the common test suite?
>
>
>
> On May 31, 2018, 11:42 AM -0400, Gleb Vinogradov <g.a.vinogradov@REDACTED>, wrote:
> > You can use CommonTest to bootstrap your application. Set environment variables, start applications etc in CommonTest and run EUnit test then.
> >
> > > 2018-05-31 22:24 GMT+07:00 Code Wiget <codewiget95@REDACTED>:
> > > > 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/7d6b3daa/attachment.htm>


More information about the erlang-questions mailing list