Writing tests for a component can be a tedious task if this component depends on another component that has an unpredictable behavior. To test such a component, we need to be able to control this unpredictable behavior. We can do that with the help of a test double. The term test double was first introduced in Gerard Meszaros’s book XUnit Test Patterns. Test double is a generic term for any kind of pretend object used in place of a real object for testing purposes. Another situation in which ...
7. Dependency Injection and Mocks
Get Modularizing Legacy Projects Using TDD: Test-Driven Development with XCTest for iOS 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.