Test Simple and Test Fast

If you’ve had experience with testing on large projects, there’s a good chance you’ve experienced a frustratingly slow test suite. If running your tests is a slow and painful process, you’re likely to stop writing tests altogether. Worse than slow tests are overly complex tests that take more work to change than the code itself. Let’s see how you can avoid these pitfalls by following a couple of common conventions.

Limit the Number of Created Modules

When you integration-test your __using__ macros, like we did in our Translator tests, you have to create a module in the test to make assertions against. This is a perfect solution, but be aware that too many modules can cause unnecessarily slow load times when running your ...

Get Metaprogramming Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.