Test-Driven Development in Swift
IntermediateWrite Swift you can change without fear. This intermediate course teaches test-driven development the way it actually works on a real codebase: you write a failing test first, make it pass with the simplest thing possible, then refactor while the suite stays green. It is built on Swift Testing, the modern framework with @Test, #expect, #require, suites, traits, and parameterized tests, and it also covers XCTest where you still need it, for UI and performance tests and for migrating an existing suite. You will go well past the basics: designing types that are testable in the first place through dependency injection and protocol seams, building stubs, spies and fakes without a mocking framework, testing async/await, actors and MainActor code deterministically instead of with sleeps, and taming legacy code with characterization tests. You will also learn what TDD does not solve, why chasing 100% coverage makes suites worse, and how to keep tests fast and free of flakiness. Assumes you already write Swift comfortably. By the end, tests will be how you design code, not a chore you do afterwards.
Course content
Certification Exam
Certification Exam
Test-Driven Development in Swift
🔒 Unlock the exam
Complete the requirements above to unlock the exam
Certification Exam
Test-Driven Development in Swift
30 Questions
All difficulty levels
45 Minutes
Auto-submits when time expires
70% to Pass
Earn your certification badge
No Going Back
Once you answer, you move forward
Tips
See allDon't Chase 100% Coverage as a Goal
Coverage counts lines executed, not whether the right thing was asserted
Keep a Fast Unit Tier Separate From a Slow Integration Tier
Tag them, and run the fast tier on every save
Diagnose a Flaky Test Instead of Retrying It Into Submission
Shared state, real time, and unordered collections are the usual suspects
Sprout a New Method Instead of Editing Untested Code in Place
New logic gets its own tested method; the old method just calls it