Mock Objects
Learn how to use mock objects for testing purposes, as well as about the potential side effects of mock objects.
We'll cover the following
Another tool that will help us in our testing efforts is the use of mock objects.
There are cases where our code is not the only thing that will be present in the context of our tests. After all, the systems we design and build have to do something real, and that usually means connecting to external services (databases, storage services, external APIs, cloud services, and so on). Because they need to have those side effects, they're inevitable. As much as we abstract our code, program toward interfaces, and isolate code from external factors to minimize side effects, they will be present in our tests, and we need an effective way to handle that.
Get hands-on with 1400+ tech skills courses.