MVI Architecture in Kotlin Multiplatform - Part 3
Article Summary
Arkadii Ivanov from Bumble Tech tackles the biggest challenge in Kotlin Multiplatform testing: no mocking frameworks. His solution? Embrace it as a feature, not a bug.
This is the final part of a three-part series on implementing MVI architecture in Kotlin Multiplatform. Ivanov covers the Kittens module with comprehensive unit and integration tests, demonstrating how to test shared code that runs on both iOS and Android without traditional mocking tools.
Key Takeaways
- Tests automatically run against all platforms—write once, multiply coverage by target count
- Fakes over mocks force better abstractions and cleaner code that's easier to modify
- TestScheduler simulates Kotlin/Native's tricky memory model without flaky multithreading
- Integration tests cover everything except UI rendering using common test code
- Manual processing mode enables testing network delays and loading states precisely
Writing test implementations instead of using mocks creates more maintainable code that automatically validates against platform-specific quirks like Kotlin/Native's memory model.
About This Article
Kotlin Multiplatform doesn't have mocking frameworks for Kotlin/Native and Kotlin/JS. Developers end up manually creating interfaces for every dependency and writing test implementations instead of using mocks.
Arkadii Ivanov's team worked with this constraint by building fake implementations like TestKittenStoreNetwork and TestKittenDataSource. They encoded responses in common formats and used TestScheduler to freeze callbacks, which let them verify Kotlin/Native memory model compatibility without needing multithreading.
The Kittens module got comprehensive test coverage across all targets with unit and integration tests that run fast and don't flake. When the code changed later, updates took much less time because the tests weren't tied to mock specifications.