Writing Swift code with great testability
summary
Shows three concrete practices: replace singletons with constructor dependency injection (but keep default arguments to retain convenience), standardize error outputs with a typed enum so tests cover predictable exits, and prefer injecting real test data (preloaded images) over heavy mocks — except where system state must be faked, e.g. add a Screen protocol to mock UIScreen.scale. Demonstrations include refactored FileLoader and ImageLoader, tests run cleanly and catch regressions; uses SwiftPlates for framework setup.
AI-written summary · about
chapters (7)
- 0:00Introduction and speaker background
- 6:21Why unit testing matters
- 11:59Design code for testability
- 19:22API boundaries with access control
- 26:47Mocking strategies and alternatives
- 38:02Summary and final tips
- 41:12Q&A session








