Wrapping Up

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

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Testing Resiliency | TOC | Chapter 4 Testing Ecto Schemas 👉

This was a hard chapter to write. OTP is undeniably one of the features that most draws developers to Erlang and Elixir. However, while the abstractions in OTP are often simple and effective, testing asynchronous and “background” code remains one of the hardest things to do in the testing landscape.

This chapter was less “preachy” compared with the other chapters in the book as a direct result of the complexity often involved in testing code that uses OTP. Our aim was to give you options and ideas to address common problems when testing OTP abstractions and asynchronous code in general. For example, we saw how to isolate the functional core of a GenServer, which is often a great approach to simplifying testing but not always possible to do. We talked about techniques for testing asynchronous code, periodic actions, and singleton resources. We finished the chapter by discussing philosophies and ideas around testing failure recovery, resiliency, and supervision trees. We hope you’ll be able to use some of these concepts and apply them to your own test suite.

Next we’re going to look at testing the most widely used libraries and frameworks in the Elixir ecosystem, Ecto and Phoenix.

Footnotes

[21] https://erlang.org/doc/man/queue.html

--

--

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.