Previously, I published support library to do parameterized test with Elixir on hex and WordPress. See here, but it in Japanese.
The library is simple macro. So, anyone can use it easily.
See readme and docs if you would like to know more
Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule ExParameterizedTest do | |
| use ExUnit.Case, async: true | |
| use ExUnit.Parameterized | |
| test_with_params "add params", | |
| fn (a, b, expected) -> | |
| assert a + b == expected | |
| end do | |
| [ | |
| {1, 2, 3} | |
| ] | |
| end | |
| test_with_params "create wordings", | |
| fn (a, b, expected) -> | |
| assert a <> " and " <> b == expected | |
| end do | |
| [ | |
| {"dog", "cats", "dog and cats"}, | |
| {"hello", "world", "hello and world"} | |
| ] | |
| end | |
| test_with_params "fail case", | |
| fn (a, b, expected) -> | |
| refute a + b == expected | |
| end do | |
| [ | |
| {1, 2, 2} | |
| ] | |
| end | |
| end |