Chapter 14. Testing in Elixir and Phoenix

This chapter covers

  • Writing tests for simple Elixir functions
  • Writing tests for Phoenix interactions
  • Using doctests to simultaneously document and test your functions

Some developers love them and write them before writing anything else, and some developers can only barely stomach them. But even developers who’d rather not write a single one can agree that they’re helpful and can be critical to a healthy application. What can cause such extremes of emotion? Tests!

Tested code can help a developer sleep better at night. Tested code allows a developer to refactor code while being confident that no regressions occur. But testing can also be tedious and time-consuming. If you’ve had bad experiences ...

Get Phoenix in Action 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.