Testing Mix Tasks

mix
testing

#1

It took me a bit to figure this all out, and I’d love to hear from others on how they test their custom tasks.

https://jc00ke.com/2017/04/05/testing-elixir-mix-tasks/


#2

Heeey! Thanks for the heads up in this! This helped me to fix my problem with a mix task test that was hiding mix messages from other apps in the same umbrella. Here is the topic I opened for the problem.

As you can see, I used Mix.shell(Mix.Shell.Process) and had problems with the umbrella apps logs. Here is the code I used to fix it:

setup do
  Mix.shell(Mix.Shell.Process)
  on_exit fn ->
    Mix.shell(Mix.Shell.IO)
  end

  :ok
end

If you could update your post with it, I guess it can be a very common problem for other people who like to make their own mix tasks. :wink: