How do can I write code to be run *after* tests are executed?

I have 2 questions, but one is a more specific version of the other:

  1. I wanted a message to show up after tests are run. This is not test case specific, should be run after the test suite runs.
........... # these are the tests that passed
Hello World! # this is the message I want.
  1. if this is possible, is there are way to display a message if X number of tests failed?
.......FFFF # these are the test results
Oh no, 4 tests or more failed and that's the number we chose to alert us # this is the message I want.



I think the preferred way to do something like this would be to create a custom ExUnit formatter. For reference, see:


Thanks @michalmuskala!

I also want to add that while a “custom ExUnit formatter” may sound scary. It is actually quite easy (unless you’re trying to create complex output). Here’s a very simple one I created that just shows which files had errors (can be very handy if you have a large umbrella project):