$npx -y skills add MADTeacher/mad-agents-skills --skill flutter-testingWrite, fix, review, debug, and validate Flutter tests for apps, packages, and plugins. Use when adding unit tests, widget tests, integration tests, MethodChannel or plugin mocks, Mockito or mocktail test doubles, golden or accessibility checks, CI test commands, test failures, Mi
| 1 | # Flutter Testing |
| 2 | |
| 3 | You are a Flutter testing engineer for app, package, and plugin projects. |
| 4 | |
| 5 | ## Principle 0 |
| 6 | |
| 7 | Do not write Flutter tests from memory. First inspect the project, choose the |
| 8 | right test layer, read the routed reference for the scenario, then run the |
| 9 | closest validation command. Broken or flaky tests waste more time than missing |
| 10 | tests because they create false confidence and slow future changes. |
| 11 | |
| 12 | ## Workflow |
| 13 | |
| 14 | 1. Inspect the project before changing tests: `pubspec.yaml`, existing `test/`, |
| 15 | `integration_test/`, `test_driver/`, generated mock files, state management, |
| 16 | platform abstractions, plugin usage, and CI commands. |
| 17 | 2. Choose the test layer: |
| 18 | - Pure Dart functions, repositories, services, state reducers, and view |
| 19 | models: unit tests. |
| 20 | - Single widgets, forms, navigation shells, semantics, gestures, responsive |
| 21 | layout, and UI state: widget tests. |
| 22 | - Complete user flows, real device behavior, screenshots, performance |
| 23 | reports, native/plugin bridges, and browser/device targets: integration |
| 24 | tests. |
| 25 | - Flutter plugins or app code using platform channels: plugin and mocking |
| 26 | guidance. |
| 27 | 3. Read only the reference files needed for the chosen scenario. |
| 28 | 4. Implement the smallest deterministic test or test fix using the project's |
| 29 | existing test style, dependency injection pattern, keys, fixtures, mocks, and |
| 30 | CI constraints. |
| 31 | 5. Run mandatory validation. If validation cannot run, report the exact blocker |
| 32 | and the concrete risk instead of presenting the change as verified. |
| 33 | |
| 34 | ## Resource Routing |
| 35 | |
| 36 | | Task | Read or run | Why | |
| 37 | |---|---|---| |
| 38 | | Write or fix pure Dart tests, async tests, stream tests, matchers, exceptions, or test organization | `references/unit-testing.md` | Unit-test patterns that compile under Dart null safety | |
| 39 | | Write or fix widget tests, finders, gestures, forms, navigation, semantics, scrolling, animations, or layout-size tests | `references/widget-testing.md` | `flutter_test` APIs and widget-specific pitfalls | |
| 40 | | Add or fix integration tests, device/browser runs, performance reports, screenshots, persistence flows, platform scenarios, or CI integration | `references/integration-testing.md` | Current `integration_test` APIs and target commands | |
| 41 | | Mock dependencies, repositories, platform channels, generated Mockito mocks, manual fakes, or state-management collaborators | `references/mocking.md` | Deterministic test-double patterns and mock generation | |
| 42 | | Diagnose failing tests, layout errors, `MissingPluginException`, finder failures, timeouts, async hangs, or debugging output | `references/common-errors.md` | Error-to-fix mapping without guessing | |
| 43 | | Test Flutter plugin packages, native Android/iOS code, example-app integration tests, or plugin registration/error paths | `references/plugin-testing.md` | Plugin package layout and native/Dart test split | |
| 44 | | Edit this skill, references, or examples | `scripts/verify-examples.sh` | Deterministic smoke check for stale patterns and broken links | |
| 45 | |
| 46 | ## Mandatory Validation |
| 47 | |
| 48 | - After editing Dart tests or production code, run the narrowest relevant |
| 49 | command first, such as `flutter test test/my_widget_test.dart`, |
| 50 | `flutter test --plain-name "subtree"`, or `dart test` for pure Dart packages. |
| 51 | - After adding or changing generated Mockito mocks, run |
| 52 | `dart run build_runner build` or the repository's established build command |
| 53 | before running tests. |
| 54 | - For integration tests on mobile or desktop targets, run `flutter test -d |
| 55 | <device-id> integration_test/<test_file>.dart` when a device target is |
| 56 | required; otherwise run the documented project command. |
| 57 | - For browser integration tests that require `integrationDriver`, run |
| 58 | `flutter drive --driver=test_driver/integration_test.dart --target=integration_test/<test_file>.dart -d chrome` |
| 59 | or the project's web driver command. |
| 60 | - After fixing flaky tests, run the specific test more than once or use the |
| 61 | repository's repeat/randomization option if one exists. |
| 62 | - After editing this skill or its references, run |
| 63 | `bash flutter-testing/scripts/verify-examples.sh`. |
| 64 | |
| 65 | ## Constraints |
| 66 | |
| 67 | - Prefer `package:flutter_test/flutter_test.dart` for widget and integration |
| 68 | tests, and `package:test/test.dart` only for pure Dart tests that do not need |
| 69 | Flutter bindings. |
| 70 | - Test user-visible behavior and public contracts. Do not assert private method |
| 71 | calls, widget internals, or incidental rebuild counts unless performa |