dart-collect-coverage

Collect Dart and Flutter test coverage and generate LCOV reports.

Updated Jul 23, 2025
One-click install
npx skills add https://github.com/derrik-fleming/dotfiles --skill dart-collect-coverage-derrik-fleming
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dart-collect-coverage
Source: https://github.com/derrik-fleming/dotfiles/tree/main/private_dot_agents/skills/dart-collect-coverage
Command: npx skills add https://github.com/derrik-fleming/dotfiles --skill dart-collect-coverage-derrik-fleming

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires coverage.

What problem does it solve? Setting up code coverage in Dart and Flutter projects involves multiple non-obvious steps: adding the coverage package as a dev dependency, running tests with the VM service enabled, collecting raw JSON coverage data, and formatting it into the standard LCOV format. This Skill guides you through the complete workflow so you get a valid lcov.info report without trial and error. ## Core Features & Use Cases - Automated Coverage Collection: Run the bundled test_with_coverage script to execute tests, gather VM coverage data, and produce coverage/lcov.info in one command. - Manual VM Service Workflow: Collect coverage manually with pause-isolates-on-exit and the VM service for granular control, including optional branch and function coverage. - Coverage Ignore Directives: Exclude lines, blocks, or entire files from metrics using coverage:ignore-line, coverage:ignore-start/end, and coverage:ignore-file comments. - Use Case: You maintain a Dart monorepo and need coverage for CI. Use this Skill to add the coverage dev dependency, run dart run coverage:test_with_coverage with explicit test directories, and validate the generated lcov.info before uploading it to your coverage dashboard. ## Quick Start Ask the assistant to set up test coverage for your Dart or Flutter project and generate an LCOV report using the coverage package.

Frequently Asked Questions about dart-collect-coverage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate an LCOV coverage report for a Dart project?▼

Add coverage as a dev dependency with dart pub add dev:coverage, then run dart run coverage:test_with_coverage. This executes your tests, collects VM coverage data, and writes coverage/lcov.info in the project root.

How to collect test coverage in a Flutter project?▼

Add the coverage package with flutter pub add dev:coverage and structure tests with flutter_test. The same test_with_coverage script collects coverage and produces an LCOV report for Flutter projects.

How do I exclude files or lines from Dart coverage reports?▼

Use inline directives: // coverage:ignore-line for one line, // coverage:ignore-start and // coverage:ignore-end for blocks, and // coverage:ignore-file for entire files. Pass --check-ignore when formatting to enforce them.

Does Dart coverage work in a monorepo workspace?▼

Yes, but you must specify test directories explicitly, for example dart run coverage:test_with_coverage -- pkgs/foo/test pkgs/bar/test. Without explicit paths, the script may not discover tests across workspace packages.

Why is my Dart coverage report missing files?▼

Files only appear in coverage if they are imported and executed by your tests. Ensure the files are exercised by test cases, or add // coverage:ignore-file if they are intentionally excluded from metrics.

Can I collect branch and function coverage in Dart?▼

Yes, use the manual workflow with collect_coverage and append --function-coverage and --branch-coverage flags. This requires Dart VM 2.17.0 or newer and running tests with the VM service enabled.