agentleFS
Atou4Atou4/skillsmith/skills/mobile/flutter-testing/SKILL.md

flutter-testing

Skill3 starsChanged 10 days agoMITView on GitHub

Write unit, widget, and integration tests with robot patterns, widget keys, and Patrol in Flutter. Use when implementing test behavior; defer CI-only configuration without test changes.

10 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use dart-concurrency, flutter-accessibility and 4 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • thiennc-tesoglobalSkill

    dart-concurrency

    Design and debug Dart asynchronous infrastructure with Future, Stream, isolates, cancellation, and lifecycle-safe ownership. Use for races, stale results, background CPU work, stream leaks, or async error handling; not for routine form-local validation or submission unless its underlying ordering mechanism is the task.

    Also in 3 projects that use this

  • thiennc-tesoglobalSkill

    flutter-accessibility

    Build or audit Flutter accessibility for semantics, screen readers, focus, keyboard access, text scaling, contrast, target size, and motion preferences. Pair with flutter-responsive-layout when large text causes reflow, clipping, or overflow across constraints.

    Also in 3 projects that use this

  • MADTeacherSkill

    flutter-navigation

    Implement, fix, refactor, review, migrate, or validate Flutter navigation and routing. Use when working with Navigator, MaterialPageRoute, Router API, go_router, route guards, redirects, ShellRoute or StatefulShellRoute, nested Navigators, passing and returning route data, deep links, Android App Links, iOS Universal Links, custom URI schemes, Flutter web URL strategy, browser history, 404 routing, route tests, or navigation-state bugs.

    Also in 3 projects that use this

  • MADTeacherSkill

    flutter-networking

    Implement, fix, debug, review, or refactor Flutter networking code for HTTP/REST APIs, WebSocket realtime flows, authentication and token refresh, request headers, timeouts, retries, JSON parsing, caching, background isolates, repositories, services, and adaptation to existing http, Dio, Retrofit, Chopper, or custom API clients. Use when asked to add network requests, investigate network errors, harden API clients, handle auth, or validate Flutter network behavior.

    Also in 3 projects that use this

  • jerelvelardeSkill

    flutter-state-management

    Flutter state management patterns — decision tree for setState, Provider, Riverpod, and BLoC with concrete examples and testing strategies

    Also in 3 projects that use this

  • +1 more from MADTeacher

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 0 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    [MOB-TEST-03] Entity Invariant & Serialization: Test calculations, validations, domain invariants, and non-trivial fromJson/toJson or …

    line 35
  2. Very specific:

    Negative Assertions: Add expectXxxNotVisible() in the robot only when absence is part of the business contract.

    line 49
  3. Very specific:

    Integration Testing: Use patrolTest with IntegrationAuthHelper.loginOrSkip($) for auth and native interactions ($.native.*) for …

    line 52
  4. Very specific:

    No local mocks: Use test/shared/. No missing bloc stub: stub state + stream.

    line 61
  5. Very specific:

    No unchecked text casing: Verify .toUpperCase() / .tr() against source.

    line 62

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Flutter Testing Standards

Priority: P0 (CRITICAL)

Universal anti-slop rules (naming, identity fixtures, tautologies, skip/focus, mock echoing, bug-first lock, sleeps, shallow assertions, coverage): anti-slop-rules.md. Only Flutter deltas follow.

Core Rule Anchors

  • [MOB-TEST-02] BLoC State Invariant: Assert transitions with isA<State>().having(...); never mirror full copyWith trees. Ban vacuous expect: () => [isA<BaseState>()] without .having(...) or verify (GUARD-DART-VACUOUS-STATE), seed echoes (GUARD-DART-SEED-ECHO), duplicate build/seed/act/expect scenarios (GUARD-DART-BLOC-DUPLICATE), and collaborator mock echoes (GUARD-DART-MOCK-ECHO).
  • [MOB-TEST-03] Entity Invariant & Serialization: Test calculations, validations, domain invariants, and non-trivial fromJson/toJson or error mapping. Ban tests of generated code and trivial getters/props.
  • [MOB-TEST-04] Contract Testing: Repositories and data sources prove contract compliance, golden JSON parsing, and error mapping; ban 1:1 pass-through echoing (when(() => dataSource.get()).thenAnswer((_) async => x); expect(await repo.get(), x)).
  • [MOB-TEST-06] Layer & Device Fidelity: Unit > Widget > Patrol integration (patrolTest). Default 800×600 widget tests never prove device layout, native permissions, or deep links; desktop emulation never substitutes native E2E.

Conventions

  1. Test Pyramid: Unit > Widget > Integration; _integration_test.dart only in integration_test/.
  2. AAA: Arrange, Act, Assert in every test.
  3. Builders: Fluent builders when setup repetition obscures intent (OrderBuilder); avoid shared global mocks.
  4. Robot-First: Route all UI interactions and assertions through the Robot pattern (extending BaseRobot), never raw find.*/expect() in a test body. Use WidgetKeys constants from lib/core/keys/; no inline Key.
  5. Negative Assertions: Add expectXxxNotVisible() in the robot only when absence is part of the business contract.
  6. Widget Testing & Mocking: TestWrapper.init() + tester.pumpLocalizedWidget(...). Register mock BLoCs with GetIt in setUpAll; stub state and stream in setUp (use whenListen, settle: false for loading states). Prohibit any().
  7. Integration Testing: Use patrolTest with IntegrationAuthHelper.loginOrSkip($) for auth and native interactions ($.native.*) for permissions, alerts, and lifecycle. For permission flows, assert the dialog (isPermissionDialogVisible) before granting or denying, and assert granted and denied outcomes as separate tests.

Anti-Patterns

  • BLoC slop (GUARD-DART-*): Ban vacuous isA<State>(), seed echoes, duplicate scenarios, and 30-property copyWith trees.
  • Test-body logic: No find.*/expect() in the test body or in integration tests without a robot.
  • Fixed sleeps (GUARD-E2E-01): Ban Future.delayed(...); use pumpAndSettle() or a condition matcher.
  • No local mocks: Use test/shared/. No missing bloc stub: stub state + stream.
  • No unchecked text casing: Verify .toUpperCase() / .tr() against source.

Verification

  • Repositories use fakes over mocks where appropriate.
  • Distinct BLoC behaviors (loading, success, error) asserted with isA<State>().having(...).
  • Views with distinct UI logic covered via the robot at the proper layer.
  • Critical user flows have at least one patrolTest integration test.
  • flutter test passes.
  • Mobile scenarios follow Mobile Testing Methodology.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.