Should it be safe to use Application put/get env in multiple tests ?
Assuming I “clean” the env at the setup of each tests, is it possible that env “leaks” between tests ?
For example this seems to work, but is there any guarantee that it won’t fail once in a blue moon ?
defmodule SUT do
def act() do
x = Application.get_env(:app, :params)[:x]
# .... Use x for whatever
end
end
defmodule Case1 do
use ExUnit.Case
setup do
Application.put_env(:app, :params, x: nil)
end
test "Code that needs x to be 0" do
Application.put_env(:app, :params, x: 0)
SUT.act()
end
test "Code that needs x to be 1" do
Application.put_env(:app, :params, x: 1)
SUT.act()
end
end
defmodule Case2 do
use ExUnit.Case
setup do
Application.put_env(:app, :params, x: nil)
end
test "Code that needs x to be 3" do
Application.put_env(:app, :params, x: 3)
SUT.act()
end
end
(In particular, I’m not clear about whetever a Process is run for each test, for each case, etc… and how it might interact with Application config…)