hazardfn

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

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

KronicDeth

The link to Virvill’s blog is dead now, but it is still available on the Internet Archive Wayback Machine

hazardfn

hazardfn

Thanks for the reply :slight_smile:,

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 :stuck_out_tongue:.

Where Next?

Popular in Questions Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
gazoon
I want to know absolute current module path. In python i could do that: os.path.abspath(__file__) Does elixir have anything similar?
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement