November 2024
Intermediate to advanced
300 pages
7h 12m
English
A method that consistently returns the same value given the same arguments and that has no side effects is a pure function. A method has side effects when it results in any fields or arguments being changed or results in any external effects (such as a database or API call). These characteristics make pure functions easier to test than their opposite ilk—impure functions.
Code designed around (predominantly) pure functions is…wait for it…functional code. You’ll look next at testing simple pure functions.
In your first stab at unit testing in Chapter 1, Building Your First JUnit Test, you started with a Zero-based test, moved onto a One-based test, then a Many-based test before ...
Read now
Unlock full access