Reputation: 31
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?
Upvotes: 2
Views: 410
Reputation: 121000
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
Upvotes: 4