npx skills add ...
npx skills add flutter/skills --skill dart-test-coverage
npx skills add flutter/skills --skill dart-test-coverage
Understand and improve test coverage in a Dart package. Helps agents run coverage, interpret results, and identify missed lines.
Guidelines for running and interpreting test coverage in Dart packages.
To find areas lacking test coverage:
Follow the workflow to generate and interpret coverage data:
dart test --coverage=.dart_tool/coverageformat_coverage as described in
the Interpreting Results section to identify specific files and missed
lines.dart test.dart test --coverage=.dart_tool/coverage.Run the following command to collect coverage in JSON format:
[!NOTE] We use
.dart_tool/coverageas the output directory because.dart_toolis typically already ignored in.gitignorefiles.
[!TIP] For projects with complex conditional logic, you can pass the
--branch-coverageflag todart testto collect branch-level coverage.
This repository includes a zero-dependency script that parses the raw JSON output and provides a summary of covered percentage and missed lines.
Run it from the project root (adjust path to script as needed):
Replace <package_name> with the name from pubspec.yaml.
Example Output:
If package:test is installed, package:coverage is likely available as a
transitive dependency. You can use its format_coverage tool.
To get a human-readable "pretty print" of the coverage:
This will output the file content with hit counts on the left (e.g., 0| for
missed lines).
When presenting coverage results to the user, follow these guidelines:
divide function is missing coverage")..dart_tool/coverage directory.lib/ files, not test/ or generated files.