A set of commands for coverage tracefiles manipulation

Coverde

A CLI for basic coverage trace files manipulation.


Installing

You can make coverde globally available by executing the following command:

$ dart pub global activate coverde

NOTE: To run coverde directly from the terminal, add the system cache bin directory to your PATH environment variable.


coverde check

Check coverage value computed from a trace file.

Parameters

Order Description Required
Unique parameter An integer between 0 and 100 used as minimum acceptable coverage value.

Options

Option Description Default value
--input
-i
Trace file used for the coverage check. coverage/lcov.info

Flags

Flag Description Default value
Enable:
--verbose
-v
Disable:
--no-verbose
Print coverage value. Enabled

Examples

  • coverde check 90
  • coverde check 75 -i lcov.info
  • coverde check 100 --no-verbose

Results

coverde filter

Filter the tested files included in a trace file.

Options

Option Description Default value
--input
-i
Coverage trace file to be filtered. coverage/lcov.info
--output
-o
Filtered coverage trace file (automatically created if it is absent). coverage/filtered.lcov.info
--filters
-f
Set of comma-separated patterns of the files to be opted out of coverage.
--mode
-m
The mode in which the filtered trace file content should be generated.
a: append content.
w: overwrite content.
a (append content)

Examples

  • coverde filter
  • coverde filter -f \.g\.dart
  • coverde filter -f \.freezed\.dart -mode w
  • coverde filter -o coverage/tracefile.info

coverde remove

Remove a set of files and folders.

Flags

Flag Description Default value
Enable:
--accept-absence
Disable:
--no-accept-absence
Set the command behavior according to a file/folder existence.
If enabled, the command continues and notifies the element absence.
If disabled, the command fails.
Enabled

Examples

  • coverde remove file.txt
  • coverde remove path/to/folder/
  • coverde remove path/to/another.file.txt path/to/another/folder/ local.folder/

coverde report

Generate HTML coverage report.

Options

Option Description Default value
--input
-i
Coverage trace file to be used as source for report generation. coverage/lcov.info
--output
-o
Destination folder where the generated report files will be placed. coverage/html/
--medium Medium threshold for coverage value. 75
--high High threshold for coverage value. 90

The report style is dynamically set according to individual, group and global coverage and the --medium and --high options.

Flags

Flag Description Default value
Enable:
--launch
-l
Disable:
--no-launch
Launch the generated report in the default browser. Disabled

Examples

  • coverde report
  • coverde report -i coverage/tracefile.info --medium 50
  • coverde report -o coverage/report --high 95 -l

Results

coverde value

Compute and display the coverage value from a trace file.

Options

Option Description Default value
--input
-i
Coverage trace file to be used for coverage value computation. coverage/lcov.info

Flags

Flag Description Default value
Enable:
--verbose
-v
Disable:
--no-verbose
Print coverage value for each source file included by the trace file. Enabled

Examples

  • coverde value
  • coverde value -i coverage/tracefile.info --no-verbose

Usage with melos

If your project uses melos to manage its multi-package structure, it could be handy to collect test coverage data in a unified trace file.

This can be achieved by defining a melos script as follows:

M:
  description: Merge all packages coverage tracefiles ignoring data related to generated files.
  run: >
    coverde rm MELOS_ROOT_PATH/coverage/filtered.lcov.info &&
    melos exec --file-exists=coverage/lcov.info -- coverde filter --input ./coverage/lcov.info --output MELOS_ROOT_PATH/coverage/filtered.lcov.info --filters \.g\.dart

M is the melos script that merges the coverage trace file of all tested packages contained within the project

This melos script ignores generated source files with the .g.dart extension but this behavior could be adjusted by setting the --filters option.

The resulting trace file is the filtered.lcov.info file, located in the coverage folder in the root folder of the project.


CI integration for coverage checks

If your project uses GitHub Actions for CI, you might already know very_good_coverage, which offers a simple but effective method for coverage validation.

However, adding coverage checks to CI workflows hosted by other alternatives is not always that straightforward.

To solve this, after enabling Dart or Flutter in your CI workflow, according to your project requirements, you can use coverde and its check tool by adding the following commands to your workflow steps:

  • dart pub global activate coverde
  • coverde check <min_coverage>

Bugs or Requests

If you encounter any problems or you believe the CLI is missing a feature, feel free to open an issue on GitHub.

Pull request are also welcome. See CONTRIBUTING.md.

GitHub

View Github