Flutter Demo by KBTG: Flutter Integration Test for Dummy
Article Summary
Amorn Apichattanakul from KBTG compares Flutter's UI testing to native iOS and doesn't hold back: 'UI test in Flutter is... horrible.' But there's a method to the madness.
This hands-on guide walks through Flutter integration testing from the perspective of an iOS developer making the switch. Amorn shares practical workarounds for Flutter's limitations, including issues with native components, animation freezes, and the lack of record mode that iOS developers take for granted.
Key Takeaways
- Flutter UI tests can't interact with native permission popups or external apps
- Use integration_test package, not deprecated Flutter Driver for cross-platform testing
- Custom pumpUntilFound function solves frozen animations during loading states
- Add keys to widgets for reliable test targeting despite debate
- Google recommends 70:20:10 ratio for unit:API:UI test coverage
Flutter's UI testing trades native iOS conveniences for true cross-platform test execution, requiring developers to code everything but testing once across all platforms.
About This Article
Amorn Apichattanakul found that spinning animations during loading would freeze the Flutter app. This prevented the integration_test package from finding widgets because pumpAndSettle() never finished.
An engineer at KBTG built a custom pumpUntilFound() function that pumps the widget tree continuously and skips animations until it finds the target widget. This let tests move forward through UI states with lots of animation.
The workaround made UI tests reliable across loading states. Developers could write cross-platform tests once and run them on all platforms at the same time without needing platform-specific record mode tools.