Coverage provides coverage data collection, manipulation, and formatting for Dart.
collect_coverage collects coverage JSON from the Dart VM Observatory.
format_coverage formats JSON coverage data into either
LCOV or pretty-printed format.
pub global activate coverage
Consider adding the
pub global run executables directory to your path.
See Running a script from your PATH
for more details.
dart --pause-isolates-on-exit --enable-vm-service=NNNN script.dart pub global run coverage:collect_coverage --uri=http://... -o coverage.json --resume-isolates
or if the
pub global run executables are on your PATH,
collect_coverage --uri=http://... -o coverage.json --resume-isolates
--uri specifies the Observatory URI emitted by the VM.
collect_coverage is invoked before the script from which coverage is to be
collected, it will wait until it detects a VM observatory to which it can
connect. An optional
--connect-timeout may be specified (in seconds). The
--wait-paused flag may be enabled, causing
collect_coverage to wait until
all isolates are paused before collecting coverage.
pub global run coverage:format_coverage --packages=app_package/.packages -i coverage.json
or if the
pub global run exectuables are on your PATH,
format_coverage --packages=app_package/.packages -i coverage.json
app_package is the path to the package whose coverage is being
--sdk-root is set, Dart SDK coverage will also be output.
--scope-outputwhich restricts coverage output so that only scripts that start with the provided path are considered.
dart:libaries by default, which provides a significant performance boost. To restore the previous behaviour and collect coverage for these libraries, use the
package:vm_service_client, which is no longer maintained, to
package:vm_service_lib, which is.
collect()now immediately throws
ArgumentErrorif a null URI is passed in the
serviceUriparameter to avoid a less-easily debuggable null dereference later. See dart-lang/coverage#240 for details.
mergeHitmapsnow specify generic types (
Map<String, Map<int, int>>) on their hit map parameter/return value.
>=1.21.0. Required for method generics.
collect_coverage. This is a temporary measure for backwards-compatibility that may stop working on Dart SDKs >= 1.22. See the related breaking change note for the Dart VM service protocol.
collectno longer supports the
portparameters. These are replaced with a
serviceUriparameter. As of Dart SDK 1.22, the Dart VM will emit Observatory URIs that include an authentication token for security reasons. Automated tools will need to scrape stdout for this URI and pass it to
--portoptions have been replaced with a
--urioption. See the above change for details.
runAndCollectnow defaults to running in checked mode.
extractObservatoryUri: scrapes an input string for an Observatory URI. Potentially useful for automated tooling after Dart SDK 1.22.
runAndCollectto run in checked mode.
basePathto constructor. Eliminated
--base-directoryoption. Source paths in LCOV/pretty-print output are relative to this directory, or absolute if unspecified.
--packagesoption for package specs.
collect_coverage: prevent hang if initial VM service connection is slow.
evaluate:sourceranges may appear in the returned source report manifesting in a crash in
collect_coverage. These generally correspond to source evaluations in the debugger and add little value to line coverage.
format_coverage: may be slower for large sets of coverage JSON input files. Unlikely to be an issue due to elimination of
Require at least Dart SDK 1.16.0.
Bugfix in format_coverage: if
--report-on is not specified, emit all
coverage, rather than none.
Formatter.format added two optional arguments:
They can be used independently to limit the files which are included in the
runAndCollect API to library.
collect top-level method.
Updated support for latest
0.11.0 dev build.
ServiceEvent.eventTypeis deprecated and will be removed in
format_coverage no longer emits SDK coverage unless --sdk-root is set
Removed support for collecting coverage from old (<1.9.0) Dart SDKs.
Optimized formatters and fixed return value of
Resolver.packageRoot – deprecated
Support the latest release of
Support the latest release of
Fixed error when trying to access invalid paths.
Require at least Dart SDK v1.9.0.
pub global run.
You can install the package from the command line:
$ pub global activate coverage
The package has the following executables:
$ collect_coverage $ format_coverage
Add this to your package's pubspec.yaml file:
dependencies: coverage: ^0.13.2
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter, other
bin/format_coverage.dart. (-1 points)
bin/format_coverage.dart reported 2 hints:
line 78 col 9: Use isNotEmpty instead of length
line 84 col 9: Use isNotEmpty instead of length
The package description is too short. (-19 points)
Add more detail to the
description field of
pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.
Maintain an example. (-10 points)
Create a short demo in the
example/ directory to show how to use this package.
Common filename patterns include
coverage.dart. Packages with multiple examples should provide
For more information see the pub package layout conventions.
|Dart SDK||>=2.1.1 <3.0.0|