Defines a module template to be used throughout your test suite.
This is useful when there are a set of setup callbacks or a set of functions that should be shared between test modules.
Once a case template is used, the regular functionality in ExUnit.Case
plus the functionality defined in the template will become available.
defmodule MyCase do use ExUnit.CaseTemplate setup do IO.puts("This will run before each test that uses this case") end end defmodule MyTest do use MyCase, async: true test "truth" do assert true end end
Allows a developer to customize the using block when the case template is used.
Allows a developer to customize the using block when the case template is used.
defmodule MyCase do use ExUnit.CaseTemplate using do quote do # This code is injected into every case that calls "use MyCase" alias MyApp.FunModule end end end
© 2012 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/ex_unit/1.11.2/ExUnit.CaseTemplate.html