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

插件详情v0.1.5

spec_cli

Spec 的 CLI 工具 - 专为 Dart 和 Flutter 设计的简化测试框架。

macOSWindowsLinux
近 30 天下载
108
喜欢数
9
Pub 分数
100

安装插件

flutter pub add spec_cli

插件介绍

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

spec_cli 是一个命令行界面工具,用于 Spec,这是一个专为 Dart 和 Flutter 应用程序设计的简化测试框架。它通过直观的命令简化了测试的创建、执行和管理。由 invertase.io 开发,该工具支持 macOS、Windows 和 Linux,使开发者能够跨平台高效运行测试。通过 `flutter pub add spec_cli` 进行最少配置即可无缝集成到现有工作流中。CLI 通过减少样板代码并在测试运行期间提供清晰反馈来提升生产力。其轻量级设计专注于速度和开发体验。

适合场景

  • 在CI/CD流水线中自动化测试执行
  • 快速生成测试文件
  • 使用最小配置运行测试
  • 与现有的 Dart/Flutter 项目集成
  • 简化测试发现和报告

主要特点

  • 用于测试管理的简单 CLI 命令
  • 跨平台支持(macOS、Windows、Linux)
  • 与 Flutter 和 Dart 的无缝集成
  • 快速测试执行和反馈
  • 内置测试文件生成

适合对象

  • Dart 和 Flutter 开发者寻求高效测试
  • 使用 CI/CD 工作流的团队
  • 希望测试时设置最少的开发者
  • 测试自动化初学者
  • 优先考虑开发者体验的项目

使用建议

  • 需要 Flutter SDK 才能获得完整功能
  • 仅限使用 Spec 测试框架的项目
  • 可能需要为复杂的测试设置进行额外配置
  • 不适用于非 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.

所属分类

依赖

依赖清单 14 项

源码仓库

使用此插件的项目

暂无相关数据。