Chapter 2 Integration and End-to-End Tests

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

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Wrapping Up | TOC | What Is an Integration Test? 👉

In the real world, it’s rare that our applications are made only of pure functions. More frequently, a production application is made of many moving pieces that interact with each other and, perhaps most importantly, with external systems as well. We want to be confident that all the pieces work together and that the integrations with external systems work correctly. However, testing becomes more complex in this scenario. For example, say our application consumes the Twitter API for sending status updates as tweets. How do we test this behavior in an automated way without publishing any tweets? How do we avoid going over the rate limits imposed by Twitter? These kinds of problems require us to rethink how we write reproducible and automated tests when the number of moving parts increases.

In this chapter we’ll learn how to design tests for Elixir systems with separate pieces interacting with each other and with external systems. This knowledge, alongside what we learned in the previous chapters, will make us able to test a system both from the perspective of simple functions and modules as well as the interactions between the components of the system.

We’ll start by having a quick look at integration tests that cover the interaction of different components within the same application. Then we’ll move on…

--

--

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.