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.

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

iloveyouboss/mock-1/src/iloveyouboss/AddressRetriever.java
 
import​ java.io.*;
 
import​ org.json.simple.*;
 
import​ org.json.simple.parser.*;
 
import​ util.*;
 
 
public​ ​class​ AddressRetriever {
 
public​ Address ...

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.