I had a quick question regarding ExUnit - it appears to start your application by default which is a different behaviour to EUnit.
I was wondering if there is a way to tell ExUnit to not start the application when running mix test, I’d like to control the start/stop of the application inside the test itself for various reasons.
Also is there a reason for this behaviour difference between ExUnit and EUnit?
Thanks for the help!
Use --no-start option as described here:
The reason is probably convenience. Most people want to start the app for the tests, I think, so that’s the default.
Thanks for the reply ,
I disagree a little with elixir doing this for unit tests as in most cases it’s a bit of an unnecessary overhead and sometimes in your Jenkins/GitLab/Travis test environment it’s not even possible to start all included applications.
EUnit tests are supposed to be lightweight, white-box function-by-function tests. ExUnit seems to be blurring the line between EUnit and CT, which may be the intention and I could just be stuck in my erlang ways.
But as you quite rightly pointed out the answer was staring me in the face in the documentation .
funny enough, I just wanted to do the same thing. So I can give you better, albeit late answer.
In order to avoid writing
mix test --no-test in command line, you can define an alias in your
mix.exs file like this:
def project do
aliases: [test: "test --no-start"],
This way, whenever you run
mix tests it will skip the starting application. Here’s a blog post I found on the subject that gives couple more extra tips:
The link to Virvill’s blog is dead now, but it is still available on the Internet Archive Wayback Machine