← ClaudeAtlas

flutter-testinglisted

Flutter testing strategy (Flutter team, Very Good Ventures, LeanCode/Patrol; verified 2026) - fakes vs mocks, unit tests with mocktail, widget tests, golden tests with Alchemist, E2E/UI tests with Patrol including native permission dialogs and notifications, device farms and sharding, Widget Previews, Widgetbook, debugging tools. Use this whenever the user writes, fixes, or plans Flutter tests, sees flaky goldens or CI test failures, needs to test permissions/notifications/native UI, picks between integration_test, Appium and Patrol, or asks how to make Flutter code testable.
abugeek/flutter-skills · ★ 0 · Testing & QA · score 72
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