跳到主内容
智客 ZICQ

技能库 智客分类:Agent 工作流 flutter-add-integration-test

Flutter Add Integration Test

配置Flustter Driver用于应用交互,并将MCP动作转换为永久集成测试. 在将集成测试添加到一个项目时使用,通过MCP探索UI组件,或者将用户流量与集成_测试包自动化.

39996 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

配置 Flustter 驱动程序用于应用程序交互,并将 MCP 动作转换为永久集成测试

何时用

在项目中添加集成测试, 通过 MCP 探索 UI 组件, 或通过集成_测试包实现用户流量自动化

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Implementing Flutter Integration Tests、Contents、Project Setup and Dependencies、Interactive Exploration via MCP、Test Authoring Guidelines、Execution and Profiling。 其中含规范建议的小节:分步指令、输入输出示例。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 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.

Implementing Flutter Integration TestsContentsProject Setup and DependenciesInteractive Exploration via MCPTest Authoring GuidelinesExecution and ProfilingWorkflow: End-to-End Integration TestingExamplesStandard Integration Test (`integration_test/app_test.dart`)Host Driver Script (`test_driver/integration_test.dart`)Performance Profiling Driver Script (`test_driver/perf_driver.dart`)

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
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.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「flutter-add-integration-test」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-8a5dbefc8fed3b68-%E5%B0%8F%E8%9D%B6%E6%B7%BB%E5%8A%A0%E6%95%B4%E5%90%88-%E6%B5%8B%E8%AF%95.html
请存为 .cursor/skills/flutter-add-integration-test/SKILL.md 或 .claude/skills/flutter-add-integration-test/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/flutter/agent-plugins' --list

npx skills add 'https://github.com/flutter/agent-plugins' --skill 'flutter-add-integration-test'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- 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](#project-setup-and-dependencies) - [Interactive Exploration via MCP](#interactive-exploration-via-mcp) - [Test Authoring Guidelines](#test-authoring-guidelines) - [Execution and Profiling](#execution-and-profiling) - [Workflow: End-to-End Integration Testing](#workflow-end-to-end-integration-testing) - [Examples](#examples) ## Project Setup and Dependencies Configure the project to support integration testing and Flutter Driver extensions. 1. Add required development dependencies to `pubspec.yaml`: ```bash flutter pub add 'dev:integration_test:{"sdk":"flutter"}' flutter pub add 'dev:flutter_test:{"sdk":"flutter"}' ``` 2. Enable the Flutter Driver extension in your application entry point (typically `lib/main.dart` or a dedicated `lib/main_test.dart`): - Import `package:flutter_driver/driver_extension.dart`. - Call `enableFlutterDriverExtension();` before `runApp()`. 3. Add `Key` parameters (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_app` with `target: "lib/main_test.dart"` to start the application and acquire the DTD URI. - **Inspect**: Execute `get_widget_tree` to discover available `Key`s, `Text` nodes, and widget `Type`s. - **Interact**: Execute `tap`, `enter_text`, and `scroll` to simulate user flows. - **Wait**: Always execute `waitFor` or verify state with `get_health` when navigating or triggering animations. - **Troubleshoot Unmounted Widgets**: If a widget is not found in the tree, it may be lazily loaded in a `SliverList` or `ListView`. Execute `scroll` or `scrollIntoView` to 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 `_test.dart` convention. - Initialize the binding by calling `IntegrationTestWidgetsFlutterBinding.ensureInitialized();` at the start of `main()`. - Load the application UI using `await tester.pumpWidget(MyApp());`. - Trigger frames and wait for animations to complete using `await tester.pumpAndSettle();` after interactions like `tester.tap()`. - Assert widget visibility using `expect(find.byKey(ValueKey('foo')), findsOneWidget);` or `findsNothing`. - 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_driver` tests, use `driver.waitFor()`, `driver.waitForAbsent()`, `driver.tap()`, and `driver.scroll()` instead of the `WidgetTester` APIs. ## 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=4444` in 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):** 1. Build debug APK: `flutter build apk --debug` 2. Build test APK: `./gradlew app:assembleAndroidTest` 3. 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_test` and `flutter_test` to `pubspec.yaml`. - [ ] Inject `enableFlutterDriverExtension()` into the app entry point. - [ ] Assign `ValueKey`s to target widgets. - [ ] **Task Progress: Exploration** - [ ] Run `launch_app` via 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 `WidgetTester` APIs. - [ ] Create `test_driver/integration_test.dart` with `integrationDriver()`. - [ ] **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 `PumpAndSettleTimedOutException` occurs, check for infinite animations -> If widget not found, add `scrollUntilVisible` -> Re-run test until passing. ## Examples ### Standard Integration Test (`integration_test/app_test.dart`) ```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`) ```dart import 'package:integration_test/integration_test_driver.dart'; Future 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. ```dart import 'package:flutter_driver/flutter_driver.dart' as driver; import 'package:integration_test/integration_test_driver.dart'; Future main() { return integrationDriver( responseDataCallback: (data) async { if (data != null) { final timeline = driver.Timeline.fromJson( data['scrolling_timeline'] as Map, ); final summary = driver.TimelineSummary.summarize(timeline); await summary.writeTimelineToFile( 'scrolling_timeline', pretty: true, includeSummary: true, ); } }, ); } ```

相关技能

Agent 工作流

Skill Creator

创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.

Agent 工作流

Clawdhub

使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.

Agent 工作流

Agent Team Orchestration

管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.

Agent 工作流

Superpowers

Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…