Chapter 26Design-for-Testability Patterns
Patterns in This Chapter
How do we design the SUT so that we can replace its dependencies at runtime?
The client provides the depended-on object to the SUT.
Almost every piece of code depends on some other classes, objects, modules, or procedures. To unit-test a piece of code properly, we would like to isolate the code from its dependencies. This isolation is difficult to achieve if those dependencies are hard-coded in the form of literal classnames.
Dependency Injection is a way to allow the normal coupling ...