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

15. Keeping Tests Isolated with Fakes and Clear with Dummies

Gio Lodi1  
(1)
Mount Martha, VIC, Australia
 

How can you keep tests isolated when the SUT relies on global state?

By shifting the dependency to in-memory with a Fake Test Double.

How can you make it clear which dependencies affect the behavior under test and which don’t?

By using a Dummy Test Double that doesn’t do anything to replace those dependencies that do not affect the behavior.

We already learned about Test Doubles, “test-specific equivalents” of the system under test dependencies, and how to use two of them. Stubs control the SUT inputs (Chapter 8 and Chapter 10), and Spies record 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.