flutter-testing
FreeNo executable scriptsNot checkedWrite unit, widget, and integration tests with robot patterns, widget keys, and Patrol in Flutter. Use when implementing test behavior; defer CI-only…
by HoangNguyen0403★ 598 GitHub starsAbout this skill
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 withisA<State>().having(...); never mirror fullcopyWithtrees. Ban vacuousexpect: () => [isA<BaseState>()]without.having(...)orverify(GUARD-DART-VACUOUS-STATE), seed echoes (GUARD-DART-SEED-ECHO), duplicatebuild/seed/act/expectscenarios (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-trivialfromJson/toJsonor 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
- Test Pyramid: Unit > Widget > Integration;
_integration_test.dartonly inintegration_test/. - AAA: Arrange, Act, Assert in every test.
- Builders: Fluent builders when setup repetition obscures intent (
OrderBuilder); avoid shared global mocks. - Robot-First: Route all UI interactions and assertions through the Robot pattern (extending
BaseRobot), never rawfind.*/expect()in a test body. UseWidgetKeysconstants fromlib/core/keys/; no inlineKey. - Negative Assertions: Add
expectXxxNotVisible()in the robot only when absence is part of the business contract. - Widget Testing & Mocking:
TestWrapper.init()+tester.pumpLocalizedWidget(...). Register mock BLoCs withGetItinsetUpAll; stubstateandstreaminsetUp(usewhenListen,settle: falsefor loading states). Prohibitany(). - Integration Testing: Use
patrolTestwithIntegrationAuthHelper.loginOrSkip($)for auth andnative 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 vacuousisA<State>(), seed echoes, duplicate scenarios, and 30-propertycopyWithtrees. - Test-body logic: No
find.*/expect()in the test body or in integration tests without a robot. - Fixed sleeps (
GUARD-E2E-01): BanFuture.delayed(...); usepumpAndSettle()or a condition matcher. - No local mocks: Use
test/shared/. No missing bloc stub: stubstate+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
patrolTestintegration test. -
flutter testpasses. - Mobile scenarios follow Mobile Testing Methodology.
Install flutter-testing in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the flutter-testing skill do?
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.
How do I install the flutter-testing skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the flutter-testing skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
by Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
by Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
by Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
by Anthropic