Mocking with Swift
summary
Explains why mocking in Swift is awkward, shows concrete refactors: add dependency injection and program to a protocol so NotificationCenter can be swapped, build a hand‑rolled mock that records calls then demonstrate its limits, and then replace it with Sorcery generating AutoMockable types so tests use generated mocks instead of 30–100 lines of boilerplate; shows Quick and Nimble are used and reports this codegen is used in production on the Jinyu Scan codebase.
AI-written summary · about
chapters (13)
- 0:00Intro
- 0:20Why Swift
- 0:55Cheese
- 2:17Testing
- 3:15Object Interaction
- 3:43Dependency Injection
- 6:18Program to Interface
- 8:22Implementation
- 10:07Test
- 11:24More Powerful Mock
- 13:56Limitations of ManualMax
- 17:38Autogenerated Tests
- 19:31Conclusion
related talks
27mReal World Mocking in Swift
24mMaking Mock Objects More Useful
52mPlease don’t mock me
37mBeyond the Mockery: Why We Should Embrace Testing Without Mocking Frameworks
31mBeyond the Mockery- Why We Should Embrace Testing Without Mocking Frameworks
39mPlease Don't Mock Me
01h 18mMocking Framworks considered, harmful?!
39mIntro to Mocking: Why Unit Testing Doesn't Have To Be So Hard
