TIL - Capturing logs in Elixir tests
Testing logging can be tricky but recently I’ve learned that Elixir’s ExUnit ships with a CaptureLog module that makes it easy to test logging behavior. I was really happy to see this built-in! Let’s say you have a function that processes a template and logs errors when something goes wrong. You want to test both the error handling and ensure the right messages are being logged. Here’s a simplified version of such a function: ...