producersto an empty array (with perhaps a log message). But there may also be valid reasons to leave it as it is. Perhaps the input object is produced by a trusted source—such as another part of the same code base. Putting in lots of validation checks between modules in the same code base can result in duplicate checks that cause more trouble than they are worth, especially if they duplicate validation done elsewhere. But if that input object is coming in from an external source, such as a JSON-encoded request, then validation checks are needed, and should be tested. In either case, writing tests like this raises these kinds of questions.
- Chapter 4 Building Tests
- from Refactoring: Improving the Design of Existing Code
- Publisher: Addison-Wesley Professional
- Released: November 2018
Share this highlighthttp://www.safaribooksonline.com/a/refactoring-improving-the/20660386/