End-to-End Tests

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

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Testing the Actual Interaction with Services | TOC | Wrapping Up 👉

End-to-end tests are tests that sit one level higher than integration tests. Instead of testing the integration between components of the system or between the system and external dependencies, end-to-end tests exercise the whole system from end to end as it might be used by the final user.

Let’s look at the weather API example from a wider perspective and think about the whole system. End-to-end tests should test the system from the perspective of a user. In this case, an end-to-end test would spin up the system and perform assertions on the observable changes. For example, the end-to-end test could start the system and then wait for an alert about rain.

The principle behind end-to-end tests is to test the real system, so using dependency doubles rarely makes sense. However, the architecture induced by dependency doubles is still useful, since we can swap the doubles for the real external dependencies when running end-to-end tests.

Unfortunately, it’s hard to find patterns for end-to-end tests when it comes to interfacing with external dependencies, since finding patterns often depends on the nature of the external dependency as well as how the system’s allowed to use it.

It’s also hard to find patterns when it comes to an end-to-end test pretending to be a user of the system…

--

--

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.