Summary
In this chapter about testing, we went through a broad range of topics. Let's review the most important ones:
- Testing in Elixir is powered by the thorough ExUnit framework, which enables us to create descriptive and concise tests that are able to run concurrently.
- We can create function mocks in Elixir using the Mox library, allowing our tests to still run concurrently. Mocks have to be created based on a behaviour, so that the API of the mock and the real implementation don't diverge.
- Ecto's modular design allows us to separate changeset tests (which verify our business logic) from repository tests (which verify our queries and the interaction with the database). In either case, we're able to run the tests concurrently.
- Elixir provides a neat feature, calledÂ
doctest
, which enables us to embed tests inside the documentation that we write. These embedded tests ensure that the documentation is kept up to date, which is a key enabler for the first-class status of documentation in the Elixir...