搜索插件、代码仓与 APP 分类

插件详情v1.2.0

flutter_test_robots

用于模拟人机交互的 Flutter 测试工具和扩展

近 30 天下载
6.4万
喜欢数
34
Pub 分数
150

安装插件

flutter pub add flutter_test_robots

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Flutter Test Robots 是一个测试工具包,旨在通过提供模拟真实人机交互的扩展来简化和增强 Flutter 应用测试。它使开发者能够编写更自然、可读性更强的测试脚本,以模拟用户操作,如点击、输入和滚动。该工具包专为与 Flutter 测试框架集成而设计,提高了测试的可靠性和可维护性。该包支持 widget 测试和集成测试,使验证复杂 UI 行为变得更加轻松,无需编写样板代码。

适合场景

  • 自动化UI交互测试
  • 在测试中模拟用户工作流程
  • 提高测试的可读性和可维护性
  • 验证表单输入和导航
  • 测试动态 UI 组件

主要特点

  • 类人交互模拟
  • 可读性强且表达清晰的测试语法
  • 与 Flutter 测试框架的集成
  • 支持小部件和集成测试
  • 可扩展且可组合的操作链

适合对象

  • Flutter 开发人员编写自动化测试
  • 注重测试质量和清晰度的团队
  • 需要复杂UI交互验证的项目
  • 使用 Flutter 的测试自动化工程师
  • 寻求减少测试不稳定的开发者

使用建议

  • 需要熟悉 Flutter 测试
  • 可能会略微增加测试套件的大小
  • 不适用于非UI测试场景
  • 除了基本示例外,文档有限
  • 最好与现有的测试框架配合使用

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Flutter Test Robots - Easily simulate human behaviors in tests

Built by the Flutter Bounty Hunters



Check out our Usage Guide


Easy keyboard shortcuts

flutter_test_robots adds methods to WidgetTester for many common keyboard shortcuts.

void main() {
  testWidgets("easy shortcuts", (tester) async {
    await tester.pressEnter();

    await tester.pressShiftEnter();
    
    await tester.pressAltLeftArrow();
  });
}

Simulate hardware keyboard text input

flutter_test_robots presses key combos for every character in a given string.

void main() {
  testWidgets("type with a hardware keyboard", (tester) async {
    // Simulate every key press that's needed to type "Hello, world!".
    await tester.typeKeyboardText("Hello, world!");
  });
}

Simulate IME text input

flutter_test_robots breaks strings into text editing deltas and sends the deltas through the standard DeltaTextInputClient API.

void main() {
  testWidgets("type with the IME", (tester) async {
    // Simulate every IME delta needed to type "Hello, world!".
    await tester.ime.typeText("Hello, world!");
  });
}

Simulate popular mobile devices

flutter_test_robots can configure a WidgetTester viewport like popular recent phones.

void main() {
  testWidgets("renders on iPhone 16 Pro Max", (tester) async {
    tester.asIPhone16ProMax();

    await tester.pumpWidget(MyApp());
  });

  testWidgets("renders on every built-in test device", (tester) async {
    for (final device in TestDevices.all) {
      tester.configureForDevice(device);

      await tester.pumpWidget(MyApp());
    }
  });
}

所属分类

源码仓库

使用此插件的项目

暂无相关数据。

所在榜单