O'Reilly logo

Quality Code: Software Testing Principles, Practices, and Patterns by Stephen Vance

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Moving Downstream

This last set of changes left me well positioned to implement the various aspects of the output. Commit [99cb54b] introduced an effective but somewhat awkward test to verify that System.out was used for normal output. I call it awkward because of the use of the copiedToOutput variable that needed checking in the override of retrieve(), shown in Listing 14-7. This amounted to a hand-rolled mock. If I left out the flag, I would have no guarantee that copyToOutput() was called and therefore that its assertion had been evaluated.

Listing 14-7: Effective but awkward test with hand-rolled mock to verify that System.out is used for output

public void testRetrieve_StandardOutput()    throws IOException, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required