2

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 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.