coverage_lens 1.0.1 copy "coverage_lens: ^1.0.1" to clipboard
coverage_lens: ^1.0.1 copied to clipboard

Static HTML coverage reports for Dart and Flutter LCOV output with compact source previews and threshold checks.

Coverage Lens #

Coverage Lens generates compact static HTML coverage reports from Dart and Flutter LCOV output. It is designed for quick local review and CI artifacts: open the report, expand the directories that need attention, and inspect source lines without leaving the browser.

Coverage Lens reads the LCOV file as the source of truth. It does not run tests, instrument code, or infer which test covered a line.

Features #

  • Static report folder with a lightweight index.html.
  • Directory tree with aggregate line and branch coverage.
  • Lazy-loaded file previews with LCOV hit counts and branch markers.
  • Lists for files below threshold and files with missing branch coverage.
  • Include and exclude globs for generated files.
  • CI-friendly threshold exit codes.

Install #

dart pub global activate coverage_lens

You can also add it to a project:

dart pub add --dev coverage_lens

Generate Coverage #

For Flutter projects:

flutter test --coverage

If your Flutter/Dart toolchain supports branch coverage and emits BRDA records, include branch coverage when generating the LCOV file:

flutter test --coverage --branch-coverage

For Dart packages, generate an LCOV file with your preferred coverage workflow, for example package:coverage.

Generate The Report #

After an LCOV file exists, run:

dart run coverage_lens:coverage_lens report \
  --lcov coverage/lcov.info \
  --source . \
  --out build/coverage_lens

Open build/coverage_lens/index.html in a browser.

The report output is a folder. Keep index.html, files/, and assets/ together when sharing or archiving the report. Source previews are stored in files/ so the main index.html stays small even for large projects.

If installed globally, use:

coverage_lens report

Configuration #

Coverage Lens reads coverage_lens.yaml from the current directory by default. Command-line options override values from the config file.

sourceRoot: .
lcovPath: coverage/lcov.info
outputDir: build/coverage_lens
thresholds:
  line: 80
  branch: 70
include:
  - lib/**
  - modules/*/lib/**
exclude:
  - "**/*.g.dart"
  - "**/*.freezed.dart"
  - "**/*.config.dart"
  - "**/generated/**"

Thresholds #

dart run coverage_lens:coverage_lens report \
  --fail-under-lines 80 \
  --fail-under-branches 70

Exit code 2 means the report was generated but the configured line coverage or branch coverage threshold failed.

LCOV Semantics #

Coverage Lens displays line and branch positions exactly as they are reported in LCOV:

  • DA:<line>,<count> marks an instrumented line and its execution count.
  • BRDA:<line>,<block>,<branch>,<taken> marks a branch record on that line.

Dart and Flutter coverage can attach counters to lines such as annotations or method declarations. Coverage Lens keeps those line numbers intact so the report matches the LCOV file it was generated from.

Ignoring Generated Files #

Use exclude patterns to keep generated code out of the report:

exclude:
  - "**/*.g.dart"
  - "**/*.freezed.dart"
  - "**/generated/**"

Excluded files are not counted in coverage totals.

0
likes
0
points
64
downloads

Publisher

unverified uploader

Weekly Downloads

Static HTML coverage reports for Dart and Flutter LCOV output with compact source previews and threshold checks.

Repository (GitHub)
View/report issues

Topics

#coverage #lcov #testing #cli #flutter

License

unknown (license)

Dependencies

args, path, yaml

More

Packages that depend on coverage_lens