Organizing Your Tests

As well as making sure our code works, our test suite serves a secondary purpose. If written well, it becomes a source of documentation for our code, with text descriptions of how we expect the code to work and working examples of how to exercise the code. This sounds like a lofty goal, but with a little organization, it’s entirely achievable. Imagine a future you looking back at code that you haven’t seen in months and trying to remember how it works and how to use it. The more organized your test suite is, the more future you will love past you for reducing the complexity of this challenge. That alone can serve as motivation to think about the overall design of your tests. Fortunately, ExUnit ships with some useful functions ...

Get Testing 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.