Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 21 [erts-10.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [hipe]
Elixir 1.8.1 (compiled with Erlang/OTP 21)
Operating system:
Linux Mint 19 and Ubuntu 14.04.5 LTS
When I run MIX_ENV=test mix dialyzer, I'm seeing a warning that Function ExUnit.Callbacks.on_exit/1 does not exist.
This happened after I added an on_exit call to the setup macro in a shared test case created using ExUnit.CaseTemplate.
So, the following test case template does not raise this warning:
defmodule MyApp.ConnCase do
use ExUnit.CaseTemplate
using do
quote do
use Phoenix.ConnTest
import MyApp.Router.Helpers
@endpoint PotionProxyWeb.Endpoint
end
end
setup _tags do
{:ok, conn: Phoenix.ConnTest.build_conn()}
end
end
But the following does raise that warning:
defmodule MyApp.ConnCase do
use ExUnit.CaseTemplate
using do
quote do
use Phoenix.ConnTest
import MyApp.Router.Helpers
@endpoint PotionProxyWeb.Endpoint
end
end
setup _tags do
on_exit(fn -> IO.puts("CALLED") end)
{:ok, conn: Phoenix.ConnTest.build_conn()}
end
end
The warning then goes away when I move the setup block inside of the quote block that's part of the using macro, like this:;
defmodule MyApp.ConnCase do
use ExUnit.CaseTemplate
using do
quote do
use Phoenix.ConnTest
import MyApp.Router.Helpers
@endpoint PotionProxyWeb.Endpoint
setup _tags do
on_exit(fn -> IO.puts("CALLED") end)
{:ok, conn: Phoenix.ConnTest.build_conn()}
end
end
end
end
All three versions of this work just fine when running my tests, by the way.
I think this is rather an issue with your .plt. Could they have been built
without ExUnit? A quick way to check Is to add :ex_unit under
Jos茅 Valim
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D
It was the PLT! Once I added :ex_unit to my dialyzer config like this:
dialyzer: [
plt_add_apps: [:mix, :distillery, :ex_unit],
check_plt: true,
ignore_warnings: "dialyzer_ignore.exs"
]
the warning went away with the code that previously was giving me a
warning.
Most helpful comment
It was the PLT! Once I added
:ex_unitto my dialyzer config like this:the warning went away with the code that previously was giving me a
warning.