flutter-add-integration-test
flutter/agent-plugins
Configure Flutter Driver and convert MCP interactions into permanent integration tests.
What is flutter-add-integration-test?
Sets up Flutter integration testing with the integration_test package and Flutter Driver extension. Use this when adding automated UI testing to a Flutter project, exploring widget interactions via MCP, or converting manual test flows into permanent test suites.
- Add integration_test and flutter_test dependencies to pubspec.yaml
- Enable Flutter Driver extension in app entry point for MCP interaction
- Discover and target widgets via ValueKey assignment and widget tree inspection
- Write WidgetTester-based integration tests in the integration_test/ directory
- Execute tests locally on Android/iOS or headless web via flutter drive command
- Profile performance metrics using binding.traceAction() and custom driver scripts
How to install flutter-add-integration-test
npx skills add https://github.com/flutter/agent-plugins --skill flutter-add-integration-test- Flutter SDK installed and configured
- Existing Flutter project with pubspec.yaml
- Access to MCP Dart/Flutter server tools for interactive exploration
How to use flutter-add-integration-test
- 1.Add integration_test and flutter_test dev dependencies via flutter pub add
- 2.Import and call enableFlutterDriverExtension() in lib/main_test.dart before runApp()
- 3.Assign ValueKey parameters to critical widgets in your app code
- 4.Create integration_test/ directory and write test files using WidgetTester APIs
- 5.Create test_driver/integration_test.dart with integrationDriver() call
- 6.Run flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart
- 7.Use MCP tools (launch_app, get_widget_tree, tap, enter_text, scroll) to explore interactions before writing tests
Use cases
- Automate user flows like login, form submission, and navigation across screens
- Explore Flutter app UI interactively via MCP before writing static tests
- Verify counter increments, text changes, and widget visibility after user actions
- Test scrollable lists by forcing widgets to mount with scrollUntilVisible
- Capture performance timelines for animations and scrolling behavior
- Flutter app developers adding automated testing to projects
- QA engineers validating UI behavior across user workflows
- Teams migrating from manual flutter_driver tests to integration_test package
- Developers profiling app performance during user interactions
flutter-add-integration-test FAQ
Assign ValueKey parameters (e.g., ValueKey('login_button')) to widgets in your app code, then use find.byKey(ValueKey('login_button')) in tests to locate and interact with them.
The widget may be lazily loaded in a SliverList or ListView. Use tester.scrollUntilVisible() or execute the scroll MCP action to force the widget to mount before interacting.
Call await tester.pumpAndSettle() after interactions like tester.tap() to trigger frames and wait for all animations to finish.
Yes. For Chrome, launch chromedriver separately then use -d chrome flag. For Android, use flutter drive directly. For Firebase Test Lab, build debug and test APKs and upload to the console.
Wrap test actions in binding.traceAction(), then use a custom driver script (test_driver/perf_driver.dart) that calls integrationDriver() with responseDataCallback to write timeline data to file.
Full instructions (SKILL.md)
Source of truth, from flutter/agent-plugins.
name: flutter-add-integration-test description: 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. metadata: model: models/gemini-3.1-pro-preview last_modified: Tue, 21 Apr 2026 18:29:20 GMT
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: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().
- Import
- 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.
- Build debug APK:
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.
- Add
- Task Progress: Exploration
- Run
launch_appvia MCP. - Map the widget tree using
get_widget_tree. - Validate interaction paths using MCP tools (
tap,enter_text).
- Run
- Task Progress: Authoring
- Create
integration_test/app_test.dart. - Write test cases using
WidgetTesterAPIs. - Create
test_driver/integration_test.dartwithintegrationDriver().
- Create
- 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.
- Run
Examples
Standard Integration Test (integration_test/app_test.dart)
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:my_app/main.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group('End-to-end test', () {
testWidgets('tap on the floating action button, verify counter', (tester) async {
// Load app widget.
await tester.pumpWidget(const MyApp());
// Verify the counter starts at 0.
expect(find.text('0'), findsOneWidget);
// Find the floating action button to tap on.
final fab = find.byKey(const ValueKey('increment'));
// Emulate a tap on the floating action button.
await tester.tap(fab);
// Trigger a frame and wait for animations.
await tester.pumpAndSettle();
// Verify the counter increments by 1.
expect(find.text('1'), findsOneWidget);
});
});
}
Host Driver Script (test_driver/integration_test.dart)
import 'package:integration_test/integration_test_driver.dart';
Future<void> main() => integrationDriver();
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.
import 'package:flutter_driver/flutter_driver.dart' as driver;
import 'package:integration_test/integration_test_driver.dart';
Future<void> main() {
return integrationDriver(
responseDataCallback: (data) async {
if (data != null) {
final timeline = driver.Timeline.fromJson(
data['scrolling_timeline'] as Map<String, dynamic>,
);
final summary = driver.TimelineSummary.summarize(timeline);
await summary.writeTimelineToFile(
'scrolling_timeline',
pretty: true,
includeSummary: true,
);
}
},
);
}
Related skills
More from flutter/agent-plugins and the wider catalog.

flutter-add-widget-preview
Add interactive widget previews to Flutter projects for real-time UI component testing and design validation.

flutter-add-widget-test
Write component-level Flutter tests using WidgetTester to verify UI rendering and user interactions.

flutter-adding-home-screen-widgets
Agent skill from flutter/agent-plugins.

flutter-animating-apps
Agent skill from flutter/agent-plugins.

flutter-apply-architecture-best-practices
Architect Flutter apps with layered separation of concerns: UI, Logic, and Data layers.

flutter-architecting-apps
Agent skill from flutter/agent-plugins.