A Testing Challenge

This lesson will cover why we use mock objects in writing Unit Tests.

We'll cover the following

It’s a safe bet that you find your own system hard to test. It might be nice to have a system that supports unit tests out of the box.

Mock objects are used to break dependencies on pain-inducing collaborators, which secures us a tool that will help us get past an ever-present hurdle.

With mocking, we’ll be able to see more benefits from our unit tests.

iloveyouboss: A testing challenge

We’re adding a new feature to the iloveyouboss application:

  • As an alternative to typing in address details, users can select a point on an interactive map that represents a Profile address.
  • The application passes the latitude and longitude coordinates for the selected point to a retrieve() method defined on the AddressRetriever class.
  • The point method should return a populated Address object based on the coordinates.

Luckily, the coding is done and it’s now our job to write a test for the retrieve() method:

Get hands-on with 1400+ tech skills courses.