I'm testing the return value of a function. Which of the two is the preferred way?
test "extra verbose, using assert" do
{:error, reason} = MyModule.my_fun
assert reason == :nope
end
test "using pattern matching only" do
{:error, :nope} = MyModule.my_fun
end
I like the first one because, I don't now, a test needs an assert
statement and the error message when running the test is more descriptive. Otoh, a MatchError
with line number should also be enough.