The problems collaborators present for testing
In this section, we will understand the challenges that arise as we grow our software into a larger code base. We will review what is meant by a collaborating object, then we will take a look at two examples of collaborations that are challenging to test.
As we grow our software system, we will soon outgrow what can go in a single class (or function, for that matter). We will split our code into multiple parts. If we pick a single object as our subject under test, any other object that it depends on is a collaborator. Our TDD tests must account for the presence of these collaborators. Sometimes, this is straightforward, as we’ve seen in earlier chapters.
Unfortunately, things aren’t always that simple. Some collaborations make tests difficult – or impossible – to write. These kinds of collaborators introduce either unrepeatable behaviors that we must contend with or present errors that are difficult to...