搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。