ExUnit.CaseTemplate

ExUnit.CaseTemplate

This module allows a developer to define a test case template to be used throughout their tests. This is useful when there are a set of functions that should be shared between tests or a set of setup callbacks.

By using this module, the callbacks and assertions available for regular test cases will also be available.

Example

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

Summary

Functions

using(var \\ quote() do _ end, list)

Allows a developer to customize the using block when the case template is used

Functions

using(var \\ quote() do _ end, list) (macro)

Allows a developer to customize the using block when the case template is used.

Example

using do
  quote do
    alias MyApp.FunModule
  end
end

© 2012–2017 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/ex_unit/1.4.5/ExUnit.CaseTemplate.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部