Verification by Injection
All but the outermost components of our system—the leaf components—rely on other components to accomplish their tasks. These other components are called collaborators, or Depended-On Components (DOCs) in Meszaros’s terminology [xTP]. Whether writing unit tests that test only the value added or when testing an integrated system, you often need to create substitutes for collaborators, known as test doubles. Especially at the unit level, injection is the most common way to introduce test doubles.
Generally speaking, dependency injection is the software-design pattern in which collaborators are inserted (i.e., injected) at runtime to satisfy the needed functionality. When testing, we can leverage various forms of dependency ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access