A collaborator is a component your software interacts with. For our purposes, we care about the components that the component under test uses to accomplish its goal. Let’s look at a reworked version of the previous
NetRetriever example (Listing 8-8).
In a more realistic example, the connection would be managed separately from the
NetRetriever. In addition to supporting the principle of separation of concerns, it abstracts the connection in a way that allows it to be reused and passed in from a larger context. While managing the open and close of the connection may not be the most neighborly or sporting approach in that design context, let’s tolerate it for now.