How do I pass the same parameter to different tests in Elixir? Now I calculate it in every test. Is it possible to calculate this parameter once before starting tests and pass it to each test?
1 Answer
Use ExUnit.Callbacks.setup/1 or ExUnit.Callbacks.setup_all/1
setup_all do
[my_param: 42]
end
test "global context", %{my_param: value} do
assert 42 == value
end