Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vic/setup_tag
Use tags to mix and match your exunit test context
https://github.com/vic/setup_tag
Last synced: 2 days ago
JSON representation
Use tags to mix and match your exunit test context
- Host: GitHub
- URL: https://github.com/vic/setup_tag
- Owner: vic
- License: apache-2.0
- Created: 2016-04-17T05:35:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-06-15T20:26:31.000Z (over 8 years ago)
- Last Synced: 2024-10-11T22:23:52.784Z (28 days ago)
- Language: Elixir
- Size: 14.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Easily mix and match functions marked with tags to setup your test context. (Testing)
- fucking-awesome-elixir - setup_tag - Easily mix and match functions marked with tags to setup your test context. (Testing)
- awesome-elixir - setup_tag - Easily mix and match functions marked with tags to setup your test context. (Testing)
README
# 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](https://hex.pm/packages/setup_tag), 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
```elixir
defmodule SetupTagTest douse 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
```