搜索分类、插件与代码仓

插件详情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 项

源码仓库

使用此插件的项目