Integration Testing for Memory Leaks
Article Summary
Matthew Healy from SoundCloud reveals how his team catches memory leaks across entire feature modules with a single test. Unit tests miss the bugs hiding between classes.
The SoundCloud iOS team uses VIPER architecture for new features, creating multiple opportunities for memory leaks through delegates, observers, and closures. Traditional unit tests only cover individual classes, leaving interaction bugs undetected until production.
Key Takeaways
- Integration tests validate entire VIPER modules by checking all components deallocate together
- Custom makeAndExpose() method exposes internal components for weak reference testing
- Approach caught previously undetected leaks in production SoundCloud modules
- Single integration test replaces dozens of individual unit tests per module
Critical Insight
One integration test per module catches memory leaks across all component interactions, providing better coverage with fewer tests than unit testing each class individually.