Wrapping Up

Testing Elixir — by Andrea Leopardi, Jeffrey Matthias (19 / 80)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Isolating Code | TOC | Chapter 2 Integration and End-to-End Tests 👉

After writing our first tests, we dug into how to define the scope of a unit test. We then explored the tools ExUnit provides us to organize our tests, rounding out our exploration with ways to design our code to be more testable: refactoring to pure functions or leveraging dependency injection. The foundation we’ve created — organizing test files, understanding the stages of a test, combining list comprehensions with assertions, and designing our code to be testable — will serve as a starting point for all of the additional concepts in this book.

In the next chapter, we’ll expand the scope of our testing black box through integration testing. You’ll see how most of the patterns can be scaled when testing across large parts of the application.

Footnotes

[8] https://elixir-lang.org/getting-started/meta/macros.html

[9] https://elixir-lang.org/getting-started/mix-otp/docs-tests-and-with.html#doctests

[10] https://en.wikipedia.org/wiki/Don%27t_repeat_yourself

[11] https://hexdocs.pm/elixir/Kernel.SpecialForms.html#unquote/1

[12] https://en.wikipedia.org/wiki/Pure_function

[13] https://hex.pm/packages/faker

Copyright © 2021, The Pragmatic Bookshelf.

👈 Isolating Code | TOC | Chapter 2 Integration and End-to-End Tests 👉

Testing Elixir by Andrea Leopardi, Jeffrey Matthias can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.