flutter-testinglisted
Install: claude install-skill abugeek/flutter-skills
# Flutter testing
Verified 2026-09-25: Flutter 3.47, patrol 4.10, alchemist 0.14, mocktail 1.0, bloc_test 10, flutter_riverpod 3.4. For Riverpod/Bloc-specific test APIs, see `flutter-state-management/references/`.
Use the testing pyramid on purpose. **Most coverage in fast unit tests of logic, widget tests for components, a few goldens for visuals, and E2E UI tests only for critical user journeys.** Each level checks something the others can't. Don't duplicate edge cases upward.
| Level | Checks | Tool |
|---|---|---|
| Unit | Business logic, Cubits/Notifiers/ViewModels, repositories, mappers, validators | `flutter_test` + `mocktail` |
| Widget | A component/screen's behavior in isolation | `flutter_test` (`patrol_finders` for nicer finders) |
| Golden | How it **looks**: design-system components | Alchemist |
| UI / E2E | The app's main purpose works end-to-end, including native UI | **Patrol** |
## Rules that apply to every level
- **Fakes over mocks** (Flutter team, "strongly recommend"). Write `FakeUserRepository implements UserRepository` with in-memory behavior in `testing/fakes/`. Mocks (mocktail) are for checking interactions or one-off stubs. Keep them **private per test file** (`class _MockApi extends Mock implements Api {}`), so a stub in one file can't leak into another.
- Name tests so the group and test names read as a sentence: `group(ShoppingCart, () { group('addItem', () { test('increases item count', ...) }) })`.
- No shared mutable state: create everyt