hazardfn
ExUnit starts your applications automatically
Hey All,
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!
/Howard
Most Liked
hubertlepicki
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
[app: :core,
...
aliases: [test: "test --no-start"],
...
deps: deps()]
end
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:
https://virviil.github.io/2016/10/26/Elixir-Testing-without-starting-supervision-tree.html
KronicDeth
The link to Virvill’s blog is dead now, but it is still available on the Internet Archive Wayback Machine
hazardfn
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
.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








