Appendix ATest Refactorings
Extract Testable Component
Also known as
Sprout Class [WEwLC]
You want to be able to test the logic easily but the component is too closely tied to its context to allow such testing.
Extract the logic you want to test into a separate component that is designed for testability and is independent of the context in which it is run.
Implementation Notes
We extract the logic from the untestable component into a component that is testable via synchronous tests, leaving behind all the ties to the context. This usually means that anything required by the testable component logic from the context is retrieved by the untestable component and passed in to the testable component as arguments of the methods under test or constructor ...
Get xUnit Test Patterns: Refactoring Test Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.