From 0% to Tested: Unit-Testing Flutter Apps with Heavy Platform Integration
Flutter apps that depend on Firebase, background services, and native platform channels present a testing problem that framework documentation does not address: a significant fraction of production code is structurally untestable at the unit level, and naive line-coverage targets obscure this reality rather than measuring quality. We report on the testing journey of Zontra, a 104,886-line production Flutter app for field workforce tracking, from zero automated tests to 2,583 tests across 292 files with 55.6% filtered line coverage. Our approach starts with a coverage-exclusion policy that separates platform-wrapper code from testable business logic. Mock boundaries using mocktail and bloc_test confine platform dependencies to thin adapter layers. Seventeen custom lint rules (built on custom_lint) keep the architecture testable. We document six cases where automated tests caught production regressions, including one that produced a new static-analysis rule and one that exposed a security-relevant routing bypass. We report costs: 53,354 lines of test code, a 0.51 test-to-source line ratio, and the effect of fakeAsync conversion on individual test files. Practitioners building Flutter apps with Firebase or native integrations can adopt the exclusion framework, mock-boundary patterns, and custom-lint rules directly.
Authors
- Sagar Ghag (ORCID: https://orcid.org/0009-0008-4164-2786)
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2026-11-16
- DOI
- https://doi.org/10.5281/zenodo.24260880
- Primary Topic
- Software Testing and Debugging Techniques
- Type
- preprint