Fast Tests
Mock objects are essential for creating unit tests that aren’t beholden to volatile external dependencies, such as the Nominatim API. An added bonus of employing mock objects: you gain tremendously faster tests.
Tremendously? There’s no unit testing standard for what fast and slow mean. Perhaps it’s personal: if you’re unwilling to wait for tests to complete and instead, forego or defer running them, they’re too slow.
Here’s another way to characterize a test’s speed: if it runs code that ultimately interacts with external dependencies—databases, files, and network calls—it’s slow. If the test otherwise executes Java code that interacts only with more Java code and no external dependencies, it’s usually fast.
Slow tests take many ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access