cover 0.8.0 copy "cover: ^0.8.0" to clipboard
cover: ^0.8.0 copied to clipboard

A simple and efficient tool for comprehensive code coverage analysis.

cover ๐ŸŽฏ #

Cover pub.dev badge cover codecov

cover is the simplest and most robust way to check your Dart/Flutter code coverage directly from the terminal or your scripts.

โœจ Features #

  • ๐Ÿ“Š Clear Reports: Generates an elegant table with coverage summaries per file.
  • ๐Ÿš€ CI/CD Ready: Returns explicit exit codes to fail pipelines if coverage is insufficient.
  • ๐Ÿ” Missing Lines: Shows exactly which line numbers are missing coverage with --show-uncovered.
  • ๐Ÿงน Smart Filters: Ignore generated files (.g.dart, .freezed.dart, etc.) with a single flag.
  • ๐Ÿค– JSON Output: Perfect for integration with other tools.
  • ๐Ÿ™ GitHub Actions: Generate coverage annotations for CI/CD pipelines with --github-annotations.
  • ๐Ÿ“‰ Regression Detection: Compare current coverage against a baseline file using --baseline.
  • ๐Ÿ›ก๏ธ Secure: Protected against ANSI injection attacks and features robust error handling.

๐Ÿ“ฆ Installation #

dart pub global activate cover

As a Dev Dependency #

Add it to your pubspec.yaml:

dev_dependencies:
  cover: ^0.5.2

๐Ÿš€ CLI Usage #

# Basic check (looks for coverage/lcov.info by default)
$ cover check

# Enforce minimum coverage and show missing lines
$ cover check --min-coverage 90 --show-uncovered

# Ignore generated files and exclude specific paths
$ cover check --exclude-generated --excluded-paths "lib/generated, lib/src/legacy"

# Get output in JSON format
$ cover check --json

# Generate GitHub Actions annotations
$ cover check --github-annotations

# Compare against a baseline (e.g. from main branch)
$ cover check --baseline coverage/lcov.base.info

Available Flags #

Flag Abbr Description Default
--path -p Path to the lcov.info file coverage/lcov.info
--min-coverage -m Minimum required coverage percentage 100.0
--show-uncovered -u Displays line numbers for missing coverage false
--exclude-generated Ignores .g.dart, .freezed.dart, etc. false
--excluded-paths -e Comma-separated paths to exclude ""
--json -j Output in JSON format false
--github-annotations -g Output GitHub Actions annotations false
--baseline -b Baseline LCOV file to compare with null

๐Ÿ› ๏ธ Programmatic Usage #

You can integrate cover directly into your Dart logic:

import 'package:cover/cover.dart';

void main() async {
  final service = CoverageService();
  
  final result = await service.checkCoverage(
    filePath: 'coverage/lcov.info',
    minCoverage: 80.0,
    excludeGenerated: true,
  );

  print('Total coverage: ${result.coverage}%');
}

๐Ÿ“ธ Output Example #

๐Ÿค Issues and Feedback #

If you find a bug or have a feature request, please open an issue in our issue tracker.

2
likes
160
points
465
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A simple and efficient tool for comprehensive code coverage analysis.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

args, cli_completion, dart_console, lcov_parser, path, pubspec_parse

More

Packages that depend on cover