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.
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.12.3
You can install packages from the command line:
$ pub get
$ flutter packages get
Alternatively, your editor might support
pub get or
flutter packages get.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|0.12.3||Oct 19, 2018|
|0.12.2||Jul 25, 2018|
|0.12.1||Jun 26, 2018|
|0.12.0||Jun 26, 2018|
|0.11.0||Apr 12, 2018|
|0.10.0||Dec 14, 2017|
|0.9.3||Oct 2, 2017|
|0.9.2||Feb 3, 2017|
|0.9.1||Jan 18, 2017|
|0.9.0||Jan 12, 2017|
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 Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter, other
The description is too short. (-20 points)
Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.
Maintain an example. (-10 points)
Create a short demo in the
example/ directory to show how to use this package. Common file name patterns include:
example.dart or you could also use
|Dart SDK||>=2.0.0-dev.64.1 <3.0.0|