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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.