Metaprogramming Elixir - Assertion (page 41-42)

The test function in the Assertion module only tests the last assert.

This is because only the last command output is returned and received by

For example:

defmodule MathTest do
  use Assertion
  test "integers can be added and subtracted" do
    assert 2 + 1 == 5
    assert 5 + 5 == 10



Even though assert 2 +1 == 5 fails, it doesn’t get returned so its never caught.

One solution is to have assert macro raise error to be caught by

@ediw8311xht thanks for your feedback. Normally the author would reply, but in this case, the author isn’t available to address questions or errata and we don’t anticipate updating the book. I wonder if the issue is due to changes in Elixir since the book was published (2015).