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());
1.
Is changing your system’s design just to write a test a bad thing?
Show Answer
Q1 / Q1
Did you find this helpful?