January 2020
Intermediate to advanced
470 pages
11h 13m
English
Yet another advantage of pure functions—and one of the most important ones—has to do with unit testing. Pure functions have a single responsibility: producing their output in terms of their input. So when you write tests for pure functions, your work is greatly simplified because there is no context to consider and no state to simulate.
You can simply focus on providing inputs and checking outputs because all function calls can be reproduced in isolation, independently from the rest of the world.
We have seen several aspects of pure functions. Let's move on and learn about impure functions a bit, and finish by testing both pure and impure functions.
Read now
Unlock full access