Dead End

I started by refactoring to create a dependency injection seam [63797de]. The idea was to inject an HttpClient mock that would allow me to inspect the resulting argument to its execute() method in retrieve-Response(). To that end, I elevated the HttpClient instance to a class field initialized in the default constructor, which I now needed to make explicit. I then factored out a constructor that took an HttpClient instance as an argument and reworked the default constructor to chain to the new one, passing a fresh instance.

In writing the test to exploit the seam, I discovered that many of the methods of DefaultHttpClient and AbstractHttpClient, including the single-argument version of execute() that the code uses, are final, preventing ...

Get Quality Code: Software Testing Principles, Practices, and Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.