flutter/packages/flutter-add-integration-test
Claude Code and agent skill by flutter/packages
- community
Checking that the SKILL.md file is still in the repository.
Configures Flutter Driver for app interaction and converts MCP actions into permanent integration tests. Use when adding integration testing to a project, exploring UI components via MCP, or automating user flows with the integration_test package.
Install
npx vskill@latest install flutter/packages/flutter-add-integration-testSKILL.md
The same SKILL.md was published earlier as flutter/packages/flutter-add-integration-test.
Implementing Flutter Integration Tests
Contents
- Project Setup and Dependencies
- Interactive Exploration via MCP
- Test Authoring Guidelines
- Execution and Profiling
- Workflow: End-to-End Integration Testing
- Examples
Project Setup and Dependencies
Configure the project to support integration testing and Flutter Driver extensions.
- Add required development dependencies to
pubspec.yaml:
``bash flutter pub add 'dev:integration_test:{"sdk":"flutter"}' flutter pub add 'dev:flutter_test:{"sdk":"flutter"}' ``
- Enable the Flutter Driver extension in your application entry point (typically
lib/main.dartor a dedicatedlib/main_test.dart):
- Import
package:flutter_driver/driver_extension.dart. - Call
enableFlutterDriverExtension();beforerunApp().
- Add
Keyparameters (e.g.,ValueKey('login_button')) to critical widgets in the application code to ensure reliable targeting during tests.
Interactive Exploration via MCP
Use the Dart/Flutter MCP server tools to interactively explore and manipulate the application state before writing static tests.
- Launch: Execute
launch_appwithtarget: "lib/main_test.dart"to start the application and acquire the DTD URI. - Inspect: Execute
get_widget_treeto discover availableKeys,Textnodes, and widgetTypes. - Interact: Execute
tap,enter_text, andscrollto simulate user flows. - Wait: Always execute
waitForor verify state withget_healthwhen navigating or triggering animations. - Troubleshoot Unmounted Widgets: If a widget is not found in the tree, it may be lazily loaded in a
SliverListorListView. ExecutescrollorscrollIntoViewto force the widget to mount before interacting with it.
Test Authoring Guidelines
Structure integration tests using the flutter_test API paradigm.
- Create a dedicated
integration_test/directory at the project root. - Name all test files using the
<name>_test.dartconvention. - Initialize the binding by calling
IntegrationTestWidgetsFlutterBinding.ensureInitialized();at the start ofmain(). - Load the application UI using
await tester.pumpWidget(MyApp());. - Trigger frames and wait for animations to complete using
await tester.pumpAndSettle();after interactions liketester.tap(). - Assert widget visibility using
expect(find.byKey(ValueKey('foo')), findsOneWidget);orfindsNothing. - Scroll to specific off-screen widgets using
await tester.scrollUntilVisible(itemFinder, 500.0, scrollable: listFinder);.
Conditional Logic for Legacy `flutter_driver`:
- If maintaining or migrating legacy
flutter_drivertests, usedriver.waitFor(),driver.waitForAbsent(),driver.tap(), anddriver.scroll()instead of theWidgetTesterAPIs.
Execution and Profiling
Execute tests using the flutter drive command. Require a host driver script located in test_driver/integration_test.dart that calls integrationDriver().
Conditional Execution Targets:
- If testing on Chrome: Launch
chromedriver --port=4444in a separate terminal, then run:
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart -d chrome
- If testing headless web: Run with
-d web-server. - If testing on Android (Local): Run
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart. - If testing on Firebase Test Lab (Android):
- Build debug APK:
flutter build apk --debug - Build test APK:
./gradlew app:assembleAndroidTest - Upload both APKs to the Firebase Test Lab console.
Workflow: End-to-End Integration Testing
Copy and follow this checklist to implement and verify integration tests.
- [ ] Task Progress: Setup
- [ ] Add
integration_testandflutter_testtopubspec.yaml. - [ ] Inject
enableFlutterDriverExtension()into the app entry point. - [ ] Assign
ValueKeys to target widgets. - [ ] Task Progress: Exploration
- [ ] Run
launch_appvia MCP. - [ ] Map the widget tree using
get_widget_tree. - [ ] Validate interaction paths using MCP tools (
tap,enter_text). - [ ] Task Progress: Authoring
- [ ] Create
integration_test/app_test.dart. - [ ] Write test cases using
WidgetTesterAPIs. - [ ] Create
test_driver/integration_test.dartwithintegrationDriver(). - [ ] Task Progress: Execution & Feedback Loop
- [ ] Run
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart. - [ ] Feedback Loop: Review test output -> If
PumpAndSettleTimedOutExceptionoccurs, check for infinite animations -> If widget not found, addscrollUntilVisible-> Re-run test until passing.
Examples
Standard Integration Test (integration_test/app_test.dart)
Host Driver Script (test_driver/integration_test.dart)
Performance Profiling Driver Script (test_driver/perf_driver.dart)
Use this driver script if you wrap your test actions in binding.traceAction() to capture performance metrics.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingthird_party/skill-repos/flutter-skills/.agents/skills/flutter-add-integration-test/SKILL.md
Popularity
- Repository stars
- 5,317
- Repository forks
- 3,998
- 7-day trend score
- 48
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/flutter/packages/flutter-add-integration-test)