Search⌘ K
AI Features

The Program Structure

Explore how to structure Elixir programs to promote responsible testing by clearly separating functional core logic from side effects. This lesson helps you design inherently testable systems using pure functions for unit testing and isolating side effects for integration testing, supporting simple refactoring and effective test coverage.

We'll cover the following...

Design strategy

The most important thing we can do to make our testing experience easier is to design an inherently testable system. To do this well, thinking about the observable effects we want to test against is crucial. In object-oriented code, the traditional approach asks us to limit ourselves to specific objects and to observe their behavior and side effects. Mocking and dependency injection help keep the test scope from growing too large.

In the case of Elixir, these practices can and will make sense when testing specific actors, although this may bring us ...