4
我试图做这样的事情不必手动编写了一系列test
块内部ExUnit.test声明:是否有可能有一个Enum.each
test_cases = %{
"foo" => 1,
"bar" => 2,
"baz" => 3,
}
Enum.each(test_cases, fn({input, expected_output}) ->
test "for #{input}" do
assert(Mymodule.myfunction input) == expected_output
end
end)
但是这段代码运行时我得到了线路assert(Mymodule.myfunction input) == expected_output
上的错误undefined function input/0
。
有没有办法实现我想要的?