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

套件詳情v0.12.20

matcher

透過可擴展的 Matcher 類別來指定測試預期值的支援。同時也包含多個常用情況的內建 Matcher 實作。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1330萬
喜歡數
68
Pub 分數
150

安裝套件

flutter pub add matcher

套件介紹

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

matcher 套件為在 Dart 中定義測試預期提供了一個彈性且可擴展的框架。它包含豐富的內建匹配器,用於常見的斷言,例如相等性、類型檢查和集合比較。開發人員也可以建立自訂匹配器,以清楚簡潔地表達複雜的驗證邏輯。此套件是使用 Dart 測試生態系統撰寫可讀性和可維護性測試的重要組成部分。

適用情境

  • 編寫具有明確斷言的單元測試
  • 驗證複雜對象結構
  • 建立可重複使用的測試條件
  • 測試集合和嵌套資料
  • 使用自定邏輯擴展測試期望

主要特色

  • 可擴展的匹配器類
  • 內建匹配器用於常見情況
  • 支援自定匹配器建立
  • 失敗時顯示清晰的錯誤訊息
  • 與 Dart 測試框架整合

適合對象

  • Dart 開發人員撰寫單元測試和整合測試
  • 優先考慮可讀性測試程式碼的團隊
  • 使用 `test` 包的項目
  • 需要表達性斷言語法的開發者
  • 那些建構測試工具或框架的人

使用建議

  • 需要 `test` 套件才能實現完整功能
  • 自定義匹配器需要仔細設計以確保清晰性
  • 如果只需要基本的相等性檢查,可能會增加開銷
  • 不打算在測試以外的執行時間進行驗證
  • 在沒有測試上下文的情況下,獨立使用有限

原始 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

所屬分類

依賴

依賴清單 5 項

原始碼儲存庫

使用此套件的專案