What problem does it solve?
Many Flutter projects suffer from fragile, slow, or non-deterministic tests due to improper mocking, missing lifecycle cleanup, unconfigured environment dependencies, and inconsistent widget test setup; this skill provides clear patterns and guardrails to make tests isolated, repeatable, and maintainable.
Core Features & Use Cases
- Layered testing guidance: explicit patterns for repository, DAO, service, and provider tests so each layer is tested in isolation.
- Riverpod & provider testing: how to override providers, use ProviderContainer helpers, and test AsyncNotifier lifecycles.
- Widget and integration testing: screen sizing, key usage, platform overrides, navigation, and async handling with Completer and pump/pumpAndSettle.
- Mocking and stubbing best practices: Mockito mock generation, when/then patterns, fake vs mock guidance, GetIt registration and reset, and SharedPreferences stubbing.
- Error handling & cleanup: test error paths, verify logging, dispose resources, and ensure deterministic results across runs.
Quick Start
Create a unit test that verifies UserRepository.fetchUsers by mocking its DAO and API with Mockito, arranging success and error scenarios and asserting expected results.