搜尋套件、儲存庫與 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());
    }
  });
}

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。

所在榜單