パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.5.0

test_coverage

Dart VM でテストを実行し、カバレッジデータを収集するためのコマンドラインユーティリティ。

30日間ダウンロード
1570
いいね数
44
Pub ポイント
30

パッケージをインストール

flutter pub add test_coverage

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

VM上でDartテストを実行し、カバレッジデータを収集するためのコマンドラインユーティリティです。開発者がテストによってコードのどの程度が実行されているかを測定できるようにし、より良いテスト品質と未テストのコードパスの特定を可能にします。このツールはCI/CDパイプラインにスムーズに統合でき、ユニットテストおよび統合テストの両方をサポートしています。さまざまな形式でカバレッジレポートを生成でき、分析やレポート作成に活用できます。シンプルさと効率性を重視して設計されており、高いテストカバレッジ基準を維持したいチームにとって特に有用です。

用途

  • CI/CDワークフローにおけるテストカバレッジの測定
  • テストされていないコード領域の特定
  • チームレビュー用のカバレッジレポートの生成
  • 自動テストパイプラインとの統合
  • リリース前のテストの完全性の検証
  • 時間の経過に伴うモニタリングカバレッジの傾向

主な機能

  • Dart VMでテストを実行する
  • 詳細なコードカバレッジデータを収集します
  • ユニットテストおよび統合テストをサポートしています
  • カバレッジレポートを生成します
  • 簡単な CLI 統合
  • Flutter および Dart プロジェクトと互換性があります

適している対象

  • Dart および Flutter 開発者
  • テスト品質に注力するチーム
  • CI/CDオートメーションエンジニア
  • カバレッジ準拠を必要とするプロジェクト
  • 開発者がテストカバレッジを向上させている
  • 品質保証チーム

注意事項

  • Dart SDK のセットアップが必要です
  • 組み込みの可視化機能なし(外部ツールが必要)
  • 仮想マシンベースのテストに限定
  • Web やモバイルプラットフォームのカバレッジデータは利用できません
  • 複雑なプロジェクトには追加の構成が必要になる場合があります
  • テスト中にホットリロードをサポートしていません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

test_coverage Build Status Pub Coverage

A simple command-line tool to collect test coverage information from Dart VM tests. It is useful if you need to generate coverage reports locally during development.

Usage

Add dev dependency to your pubspec.yaml:

dev_dependencies:
  test_coverage: ^0.4.2

Run pub get to install. Then, in the root of your project run:

pub run test_coverage

Result is saved in coverage/lcov.info. If you have lcov tool installed on your system (for Mac it's brew install lcov) you can generate coverage reports using genhtml command:

genhtml -o coverage coverage/lcov.info
# Open in the default browser (mac):
open coverage/index.html

Integrations

Resulting coverage/lcov.info file is ready to be consumed by Codecov command-line tool, so no extra step is needed.

This library was not tested with coveralls yet.

Generating badge image

Coverage

Coverage badge SVG image is automatically generated and saved to coverage_badge.svg in your project root directory. You can add it to Git and use in README.md on Github as follows:

![Coverage](https://raw.githubusercontent.com/{you}/{repo}/master/coverage_badge.svg?sanitize=true)

If you don't need it you can pass --no-badge flag when running test coverage.

Known limitations

  • This library was created to run Dart VM tests. It has not been tested and likely won't work for Dart code targeting web platform (compiled to JavaScript). There is no need to use this tool for Flutter as it allows collecting coverage information with flutter test --coverage.

How it works

The tool performs following steps:

1. Generates test/.test_coverage.dart file (a "test all" script).

Scans your test/ directory to find all *_test.dart files and creates test/.test_coverage.dart which imports all found test files and runs corresponding main() of all tests functions within the same file (and process), which simplifies collection of coverage information.

It is recommended to add this file to your .gitignore.

Below is an example of test/.test_coverage.dart:

// Auto-generated by test_coverage. Do not edit by hand.
// Consider adding this file to your .gitignore.

import 'some_test.dart' as some_test;
import 'nested/other_test.dart' as other_test;
import 'some_other_test.dart' as some_other_test;

void main() {
  some_test.main();
  other_test.main();
  some_other_test.main();
}
2. Runs the tests

Following command is used to run the tests:

dart --pause-isolates-on-exit --enable_asserts --enable-vm-service \
  test/.test_coverage.dart
3. Collects and formats coverage information

When test execution is completed the tool uses functionality of the coverage package to collect and format coverage report.

Feel free to file feature requests and bug reports at the issue tracker.

4. Minimal coverage percentage

Set minimal coverage percentage to pass min-coverage percentage value of coverage.

5. See test output

print-test-output to show test output.

Show output of tests

Feel free to file feature requests and bug reports at the issue tracker.

カテゴリー

依存関係

依存関係一覧 5 件

ソースリポジトリ

このパッケージを使用しているプロジェクト