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

插件详情v0.2.1

dart_test_adapter

提供一个 Dart API,用于以编程方式与 `dart test`/`flutter test` 交互

AndroidiOSmacOSWindowsLinux
近 30 天下载
443
喜欢数
7
Pub 分数
130

安装插件

flutter pub add dart_test_adapter

插件介绍

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

dart_test_adapter 包提供了一个 Dart API,可编程地与 `dart test` 和 `flutter test` 命令进行交互。它使开发者能够在 Dart 应用程序中运行测试、解析结果并管理测试执行,非常适合将测试工作流程集成到自定义工具或 CI/CD 管道中。该包专为 Android、iOS、macOS、Windows 和 Linux 上的开发环境设计,无需依赖 shell 脚本即可无缝自动化和控制测试运行。该包由 invertase.io 维护,且为开源。

适合场景

  • 在CI/CD流水线中自动化测试执行
  • 将测试运行器集成到自定义开发工具中
  • 程序化分析测试结果
  • 从 Dart 应用程序内部运行测试
  • 启用动态测试配置

主要特点

  • 程序化访问测试运行器
  • 跨平台支持
  • 与 Flutter 和 Dart 测试框架的集成
  • 实时结果解析
  • 开源且持续维护

适合对象

  • CI/CD 自动化工程师
  • 测试框架开发人员
  • 工具创建者
  • Dart/Flutter 应用维护者

使用建议

  • 需要正确设置测试环境
  • 可能需要为复杂的测试套件添加额外的错误处理
  • 不打算用于直接的终端用户测试执行
  • 最好在后端或工具链上下文中使用,而不是在应用逻辑中

原始 README

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

✅ Spec

A streamlined testing framework for Dart & Flutter.

Melos docs.page Chat on Discord

What is it?

Spec builds on-top of existing Dart & Flutter testing tools to provide a streamlined & elegant testing environment. Spec provides both a CLI tool and Dart package.

CLI

The Spec CLI allows you to run the spec command from your CLI environment and run your tests:

  • Intuitive testing output interface, inspired by Jest.
  • Interactive CLI (via spec --watch); automatically re-run tests when source code changes & rerunning of only failed tests.
  • Run both Dart & Flutter tests in parallel with a single command.
  • Run tests from multiple packages at the same time using Melos.

spec

Package

The spec package provides a different take on how to write tests. Designed with type-safety and IDE autocompletion in mind, spec alters the way you write your tests to be more declarative, less error prone and force good habits.

Getting Started

Matchers

Spec CLI works alongside normal Dart test matchers, however also ships with custom matchers, see the API reference docs.

Example of testing using Spec matchers:

import 'package:spec/spec.dart';

void main() {
  test('future example', () async {
    final future = Future.value(42);
    expect(future).toEqual(future);
    await expect(future).completion.toEqual(42);
    await expect(future).throws.isArgumentError();
  });

  test('stream example', () async {
    final stream = Stream.value(42);
    await expect(stream).emits.toEqual(42);
    await expect(stream).emits.isNull();
    await expect(stream).emits.not.isNull();
    await expect(stream).emitsError.isArgumentError();
  });

  test('function example', () {
    void throwsFn() => throw Error();
    expect(throwsFn).returnsNormally();
    expect(throwsFn).throws.isArgumentError();
  });
}
CLI
Installation
dart pub global activate spec_cli
Usage

Run tests:

spec

Run tests in interactive mode:

spec --watch

Interactive mode supports a number of keyboard shortcuts:

Watch Usage:
 › Press f to run only failed tests.
 › Press t to filter by a test name regex pattern.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.
GitHub Action

If you want to use Spec in your GitHub actions pipeline you can utilize the Spec GitHub action, instructions for how to use it can be found on the the spec-action's marketplace page and in its repository.


LICENSE

Built and maintained by Invertase.

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目

暂无相关数据。