Skip to content

Toolkit Extensions

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.

coverageA package under the line threshold fails the pipelineNeeds Pro

Step 1 of 4, init: coverage init writes a coverage.yaml at the workspace root. The default line threshold is 80 percent, and generated files such as *.g.dart are excluded. Running it again only warns.

Threshold: 80 percent of lines

dart run monorepo_toolkit coverage init✓ Created coverage.yaml at /path/to/my_workspace/coverage.yaml
coverage.yaml
infrastructure/network_sdk_api/coverage/lcov.info

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 each package's coverage/lcov.info and checks it against 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).

How each setting is applied:

  • exclude_patterns and exclude_files drop matching files from the report before check and combine count it. A pattern without / matches the file name in any folder (*.g.dart). A pattern with / matches the path from the package root (lib/main_*.dart). ** matches any number of folders. A package's patterns are added to the global ones.
  • min_line_threshold always applies.
  • min_branch_threshold and min_function_threshold apply only when the report has branch or function data. flutter test --coverage writes neither by default. Add --branch-coverage to get branch data. Flutter writes branch records (BRDA) without a BRF/BRH summary, so the check counts the records itself. Flutter writes no function data, so min_function_threshold applies only to reports from other tools.

CI integration ​

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