Skip to content
/ setup_tag Public

Use tags to mix and match your exunit test context

License

Notifications You must be signed in to change notification settings

vic/setup_tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SetupTag

SetupTag allows you to create a test context by easily mix and match test setup functions selected by the tags applied to your test or module.

Deprecated since elixir 1.0.3.rc-1 has setup in exunit core.

Installation

Available in Hex, the package can be installed as:

  1. Add setup_tag to your list of dependencies in mix.exs:

    def deps do [{:setup_tag, "~> 0.1.2", only: [:test}] end

Usage

See setup_tag_text.exs for a complete example

defmodule SetupTagTest do

  use ExUnit.Case
  use SetupTag
  
  def one(ctx), do: {:ok, Map.put(ctx, :one, 1)}
  def dup_one(ctx = %{one: x}), do: {:ok, %{ctx | one: x + x }}
  def mul_one(ctx = %{one: x}, y), do: {:ok, %{ctx | one: x * y }}
  
  @tag setup: [:one, :dup_one, mul_one: 3]
  test "combining with a function with arguments", %{one: x} do
    assert x == 6
  end
end

About

Use tags to mix and match your exunit test context

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages