Changing Our Design to Support Testing
Learn how we can change the system's design to support JUnit testing.
We'll cover the following
Our new code represents a small change to the design of the system. Before, the Http
instance was created by the retrieve()
method as a private detail of the AddressRetriever
class. Now, any client that interacts with AddressRetriever
is responsible for creating and passing in an appropriate Http
instance. Perhaps something like:
AddressRetriever retriever = new AddressRetriever(new HttpImpl());
Get hands-on with 1200+ tech skills courses.