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
# 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 fullSubcommands
coverage init
Creates a coverage.yaml config template at the workspace root with sensible defaults:
dart run monorepo_toolkit coverage initcoverage run
Runs flutter test --coverage across all workspace packages:
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| Flag | Abbr | Default | Description |
|---|---|---|---|
--concurrency | -j | 1 | Number of packages to test in parallel |
--package | -p | all | Run tests for a specific package only |
--fail-fast | true | Stop on first failure |
coverage combine
Merges per-package lcov.info files into a single combined report:
dart run monorepo_toolkit coverage combine
dart run monorepo_toolkit coverage combine -o coverage/combined.lcov| Flag | Abbr | Description |
|---|---|---|
--output | -o | Output file path for the combined lcov report |
coverage check
Reads the combined report and verifies that all packages meet the configured thresholds:
dart run monorepo_toolkit coverage checkExits with code 1 if any package falls below its threshold.
coverage full
Runs the complete pipeline in sequence -- tests, combine, then check:
dart run monorepo_toolkit coverage full
dart run monorepo_toolkit coverage full -j 4| Flag | Abbr | Default | Description |
|---|---|---|---|
--concurrency | -j | 1 | Number of packages to test in parallel |
--fail-fast | true | Stop on first failure |
Configuration
Create a coverage.yaml at the workspace root (or run coverage init):
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: truePer-package settings override global defaults. Use skip: true to exclude packages that have no meaningful testable code (e.g., noop implementations).
CI integration
steps:
- name: Run coverage pipeline
run: dart run monorepo_toolkit coverage full -j 4