Good tests make a concrete claim, control the inputs relevant to that claim, and fail clearly when the behavior is wrong. This guide follows a path from your first unit test to asynchronous work, real adapter boundaries, UI journeys, and useful CI feedback.
The section contains eight articles. Start with the introduction, use FIRST to review test quality, then choose the boundary your next test needs to prove. Unit, integration, and UI tests provide different evidence; none replaces all the others.
Examples identify their Swift and framework requirements. Most use XCTest with a Swift 5.7 baseline. The coverage and CI article introduces Swift Testing from the Swift 6 toolchain after its September 2024 release. Within each article, read the Swift blocks in order unless a block explicitly names a separate app or test target.
Article available Coming soon
1. Foundations
Gentle Introduction To Unit Testing.
One crisp Monday morning, a fresh-faced software engineer, affectionately nicknamed Penguin 🐧, embarked on their inaugural journey into the professional realm, commencing...
FIRST Principles for Reliable Swift Tests
FIRST is a way to review whether a unit test gives useful feedback at a sustainable cost. A test should be fast...
Test Doubles In Swift
The term test doubles draws inspiration from stunt doubles in the movie industry, where a stunt double steps in to perform dangerous...
2. Time and Concurrency
Testing Asynchronous Swift Code
An asynchronous test should establish when an operation completed and what happened because of it. Waiting for an arbitrary amount of time...
How to Avoid Flaky Tests in Swift
A flaky test passes and fails with the same code under conditions the test did not control. The cause may be a...
3. Real Boundaries and User Journeys
Integration Testing in Swift: Networking and Storage
An integration test checks that real components honor their shared contract. A test using a fake repository can establish how a screen...
Reliable UI Testing in Swift
A UI test should verify a user-visible journey through the assembled application. It can catch missing event wiring, navigation problems, and state...
4. Keeping the Suite Useful
Swift Test Coverage, Test Plans, and CI
Coverage tells you which instrumented code executed. It does not tell you whether the test checked the right outcome. CI should combine...
Up next
Swift Concurrency