Skip to content

Test Coverage Pipeline Pro

The coverage command provides a complete test coverage pipeline: run tests with coverage collection, merge per-package lcov reports into a single workspace report, and enforce minimum coverage thresholds.

Usage

bash
# Initialize a coverage.yaml config template
dart run monorepo_toolkit coverage init

# Run tests with coverage collection
dart run monorepo_toolkit coverage run

# Merge per-package lcov reports
dart run monorepo_toolkit coverage combine

# Verify coverage meets thresholds
dart run monorepo_toolkit coverage check

# All-in-one: run + combine + check
dart run monorepo_toolkit coverage full

Subcommands

coverage init

Creates a coverage.yaml config template at the workspace root with sensible defaults:

bash
dart run monorepo_toolkit coverage init

coverage run

Runs flutter test --coverage across all workspace packages:

bash
dart run monorepo_toolkit coverage run
dart run monorepo_toolkit coverage run -j 4           # 4 packages in parallel
dart run monorepo_toolkit coverage run -p auth_impl   # Single package only
dart run monorepo_toolkit coverage run --no-fail-fast  # Continue after failures
FlagAbbrDefaultDescription
--concurrency-j1Number of packages to test in parallel
--package-pallRun tests for a specific package only
--fail-fasttrueStop on first failure

coverage combine

Merges per-package lcov.info files into a single combined report:

bash
dart run monorepo_toolkit coverage combine
dart run monorepo_toolkit coverage combine -o coverage/combined.lcov
FlagAbbrDescription
--output-oOutput file path for the combined lcov report

coverage check

Reads the combined report and verifies that all packages meet the configured thresholds:

bash
dart run monorepo_toolkit coverage check

Exits with code 1 if any package falls below its threshold.

coverage full

Runs the complete pipeline in sequence -- tests, combine, then check:

bash
dart run monorepo_toolkit coverage full
dart run monorepo_toolkit coverage full -j 4
FlagAbbrDefaultDescription
--concurrency-j1Number of packages to test in parallel
--fail-fasttrueStop on first failure

Configuration

Create a coverage.yaml at the workspace root (or run coverage init):

yaml
global:
  min_line_threshold: 80
  min_branch_threshold: 70
  min_function_threshold: 80

  exclude_patterns:
    - "*.g.dart"
    - "*.freezed.dart"
    - "*.config.dart"
    - "*.module.dart"
    - "*.gr.dart"
    - "**/generated/**"

  exclude_files:
    - "lib/main.dart"
    - "lib/bootstrap.dart"
    - "**/injector.dart"
    - "**/register_module.dart"

packages:
  auth_impl:
    min_line_threshold: 90
  monitoring_noop:
    skip: true

Per-package settings override global defaults. Use skip: true to exclude packages that have no meaningful testable code (e.g., noop implementations).

CI integration

yaml
steps:
  - name: Run coverage pipeline
    run: dart run monorepo_toolkit coverage full -j 4

Built by Banua Coder