© Gio Lodi 2021
G. LodiTest-Driven Development in Swifthttps://doi.org/10.1007/978-1-4842-7002-8_8

8. Testing Code Based on Indirect Inputs

Gio Lodi1  
(1)
Mount Martha, VIC, Australia
 

How do you test behavior that depends on indirect inputs in isolation?

By building a test-specific replacement for the dependency, which you can use to control the indirect inputs it provides to the system under test.

We’re in the middle of building the UI component of the new menu fetching from a remote API functionality. We started from the UI to have an Earliest Testable version of the dynamic update, but that means we don’t have the real networking component yet.

In the previous chapter, we applied the Dependency Injection Principle and defined an abstraction for the ...

Get Test-Driven Development in Swift: Compile Better Code with XCTest and TDD 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.