Search code examples
elixirelixir-mix

Elixir: How to run tests with "mod" set inside mix.exs?


In my mix.exs I have:

...
def application do
  [
    mod: {MyProject, []},
    extra_applications: [:logger]
  ]
end
...

I use the mod in order to execute my project (e.g.: mix run myproject ARGS). However, when I try to run mix test, it seems to execute MyProject.start with the parameter test.

If I comment out the mod-line inside mix.exs, mix test runs successfully.

Is there a way I can do both, run the project and run the tests without changing the mix.exs? Or do I need to run my tests differently?


Solution

  • The issue was unrelated. I did not exit the application properly. Exiting the def start(_type, _args) do function with {:ok, Kernel.self()} makes the mix test run the tests.