搜尋分類、套件與程式碼儲存庫

套件詳情v1.3.3

fake_async

用於確定性測試的虛擬異步事件,例如計時器和微任務。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1030萬
喜歡數
123
Pub 分數
150

安裝套件

flutter pub add fake_async

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

fake_async 是一個專為異步程式碼確定性測試設計的 Dart 套件。它允許開發者在受控環境中模擬計時器、微任務及其他非同步事件,確保測試結果具備可預測性和重複性。透過偽造非同步行為,它消除了對真實時間延遲的依賴,讓測試更快速且更可靠。非常適合包含非同步操作(例如 futures、streams 或排程任務)的單元測試與整合測試。

適用情境

  • 測試非同步程式碼而不使用實際延遲
  • 模擬計時器和微任務
  • 撰寫確定性單元測試
  • 驗證流和未來邏輯
  • 提高測試性能

主要特色

  • 控制異步操作的時機
  • 支援微任務和定時器偽造
  • 啟用精確的測試執行
  • 與測試包整合
  • 提供用於異步模擬的乾淨 API

適合對象

  • Dart 開發人員撰寫單元測試
  • 優先考慮測試可靠性的團隊
  • 具有複雜異步工作流程的專案
  • 測試驅動開發實踐
  • 需要快速測試的CI/CD流水線

使用建議

  • 不適用於端對端測試
  • 需要理解事件循環
  • 僅限測試環境
  • 不會在生產環境中取代真實的非同步行為
  • 測試檔案中需要正確設定

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Dart CI OpenSSF Scorecard

What's here?

Welcome! package:test is the standard testing library for Dart and Flutter. If you have questions about Dart testing, please see the docs for package:test. package:test_api and package:test_core are implementation details and generally not user-facing.

package:checks is a relatively new library for expressing test expectations. It's a more modern version of package:matcher and features a literate API.

Packages

Package Description Issues Version
checks A framework for checking values against expectations and building custom expectations. issues pub package
fake_async Fake asynchronous events such as timers and microtasks for deterministic testing. issues pub package
matcher Support for specifying test expectations via an extensible Matcher class. Also includes a number of built-in Matcher implementations for common cases. issues pub package
test A full featured library for writing and running Dart tests across platforms. issues pub package
test_api The user facing API for structuring Dart tests and checking expectations. pub package
test_core A basic library for writing tests and running them on the VM. pub package
test_descriptor An API for defining and verifying files and directory structures. issues pub package
test_process Test processes: starting; validating stdout and stderr; checking exit code. issues pub package

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案