coverage 0.12.4

  • Installing
  • Versions
  • 89

Coverage #

Coverage provides coverage data collection, manipulation, and formatting for Dart.

Build Status Coverage Status Pub

Tools #

collect_coverage collects coverage JSON from the Dart VM Observatory. format_coverage formats JSON coverage data into either LCOV or pretty-printed format.

Install coverage #

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.

Collecting coverage from the VM #

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

where --uri specifies the Observatory URI emitted by the VM.

If 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.

Formatting coverage data #

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

where app_package is the path to the package whose coverage is being collected. If --sdk-root is set, Dart SDK coverage will also be output.

0.12.4 - 2019-01-11 #

  • collect() now immediately throws ArgumentError if a null URI is passed in the serviceUri parameter to avoid a less-easily debuggable null dereference later. See dart-lang/coverage#240 for details.

0.12.3 - 2018-10-19 #

  • Fixed dart-lang/coverage#194. During collection, we now track each script by its (unique) VMScriptRef. This ensures we look up the correct script when computing the affected line for each hit token. The hitmap remains URI based, since in the end, we want a single, unified set of line to hitCount mappings per script.

0.12.2 - 2018-07-25 #

  • Dart SDK upper bound raised to <3.0.0.

0.12.1 - 2018-06-26 #

  • Minor type, dartfmt fixes.
  • Require package:args >= 1.4.0.

0.12.0 - 2018-06-26 #

  • BREAKING CHANGE: This version requires Dart SDK 2.0.0-dev.64.1 or later.
  • Strong mode fixes as of Dart SDK 2.0.0-dev.64.1.

0.11.0 - 2018-04-12 #

  • BREAKING CHANGE: This version requires Dart SDK 2.0.0-dev.30 or later.
  • Updated to Dart 2.0 constants from dart:convert.

0.10.0 - 2017-12-14 #

  • BREAKING CHANGE: createHitmap and mergeHitmaps now specify generic types (Map<String, Map<int, int>>) on their hit map parameter/return value.
  • Updated package:args dependency to 1.0.0.

0.9.3 - 2017-10-02 #

  • Strong mode fixes as of Dart SDK 1.24.0.
  • Restrict the SDK lower version constraint to >=1.21.0. Required for method generics.
  • Eliminate dependency on package:async.

0.9.2 - 2017-02-03 #

  • Strong mode fixes as of Dart SDK 1.22.0.

0.9.1 - 2017-01-18 #

  • Temporarily add back support for the --host and --port options to 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.

0.9.0 - 2017-01-11 #

  • BREAKING CHANGE: collect no longer supports the host and port parameters. These are replaced with a serviceUri parameter. 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 collect_coverage.
  • BREAKING CHANGE: collect_coverage: the --host and --port options have been replaced with a --uri option. See the above change for details.
  • BREAKING CHANGE: runAndCollect now defaults to running in checked mode.
  • Added extractObservatoryUri: scrapes an input string for an Observatory URI. Potentially useful for automated tooling after Dart SDK 1.22.

0.8.1 #

  • Added optional checked parameter to runAndCollect to run in checked mode.

0.8.0+2 #

  • Strong mode fixes as of Dart SDK 1.20.1.

0.8.0+1 #

  • Make strong mode clean.

0.8.0 #

  • Moved Formatter.format parameters reportOn and basePath to constructor. Eliminated pathFilter parameter.

0.7.9 #

  • format_coverage: add --base-directory option. Source paths in LCOV/pretty-print output are relative to this directory, or absolute if unspecified.

0.7.8 #

  • format_coverage: support --packages option for package specs.

0.7.7 #

  • Add fallback URI resolution for Bazel http(s) URIs that don't contain a packages path component.

0.7.6 #

  • Add Bazel support to format_coverage.

0.7.5 #

  • Bugfix in collect_coverage: prevent hang if initial VM service connection is slow.
  • Workaround for VM behaviour in which evaluate:source ranges 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 --coverage-dir VM flag.

0.7.4 #

  • Require at least Dart SDK 1.16.0.

  • Bugfix in format_coverage: if --report-on is not specified, emit all coverage, rather than none.

0.7.3 #

  • Added support for the latest Dart SDK.

0.7.2 #

  • Formatter.format added two optional arguments: reportOn and pathFilter. They can be used independently to limit the files which are included in the output.

  • Added runAndCollect API to library.

0.7.1 #

  • Added collect top-level method.

  • Updated support for latest 0.11.0 dev build.

  • Replaced ServiceEvent.eventType with ServiceEvent.kind.

    • ServiceEvent.eventType is deprecated and will be removed in 0.8.

0.7.0 #

  • format_coverage no longer emits SDK coverage unless --sdk-root is set explicitly.

  • Removed support for collecting coverage from old (<1.9.0) Dart SDKs.

  • Removed deprecated Resolver.pkgRoot.

0.6.5 #

  • Fixed early collection bug when --wait-paused is set.

0.6.4 #

  • Optimized formatters and fixed return value of format methods.

  • Added Resolver.packageRoot – deprecated Resolver.pkgRoot.

0.6.3 #

  • Support the latest release of args package.

  • Support the latest release of logging package.

  • Fixed error when trying to access invalid paths.

  • Require at least Dart SDK v1.9.0.

0.6.2 #

  • Support observatory protocol changes for VM >= 1.11.0.

0.6.1 #

  • Support observatory protocol changes for VM >= 1.10.0.

0.6.0+1 #

  • Add support for pub global run.

0.6.0 #

  • Add support for SDK versions >= 1.9.0. For Dartium/content-shell versions past 1.9.0, coverage collection is no longer done over the remote debugging port, but via the observatory port emitted on stdout. Backward compatibility with SDKs back to 1.5.x is provided.

Use this package as an executable

1. Install it

You can install the package from the command line:

$ pub global activate coverage

2. Use it

The package has the following executables:

$ collect_coverage
$ format_coverage

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  coverage: ^0.12.4

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:coverage/coverage.dart';
Version Uploaded Documentation Archive
0.12.4 Jan 11, 2019 Go to the documentation of coverage 0.12.4 Download coverage 0.12.4 archive
0.12.3 Oct 19, 2018 Go to the documentation of coverage 0.12.3 Download coverage 0.12.3 archive
0.12.2 Jul 25, 2018 Go to the documentation of coverage 0.12.2 Download coverage 0.12.2 archive
0.12.1 Jun 26, 2018 Go to the documentation of coverage 0.12.1 Download coverage 0.12.1 archive
0.12.0 Jun 26, 2018 Go to the documentation of coverage 0.12.0 Download coverage 0.12.0 archive
0.11.0 Apr 12, 2018 Go to the documentation of coverage 0.11.0 Download coverage 0.11.0 archive
0.10.0 Dec 14, 2017 Go to the documentation of coverage 0.10.0 Download coverage 0.10.0 archive
0.9.3 Oct 2, 2017 Go to the documentation of coverage 0.9.3 Download coverage 0.9.3 archive
0.9.2 Feb 3, 2017 Go to the documentation of coverage 0.9.2 Download coverage 0.9.2 archive
0.9.1 Jan 18, 2017 Go to the documentation of coverage 0.9.1 Download coverage 0.9.1 archive

All 46 versions...

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]
Learn more about scoring.

We analyzed this package on Jun 4, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.17


Detected platforms: Flutter, other

Primary library: package:coverage/coverage.dart with components: io.

Health suggestions

Fix bin/format_coverage.dart. (-1 points)

Analysis of 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

Fix lib/src/collect.dart. (-0.50 points)

Analysis of lib/src/collect.dart reported 1 hint:

line 42 col 7: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

Fix lib/src/resolver.dart. (-0.50 points)

Analysis of lib/src/resolver.dart reported 1 hint:

line 96 col 36: Use = to separate a named parameter from its default value.

Fix lib/src/run_and_collect.dart. (-0.50 points)

Analysis of lib/src/run_and_collect.dart reported 1 hint:

line 14 col 17: Use = to separate a named parameter from its default value.

Maintenance suggestions

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 main.dart, example.dart, and coverage.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.64.1 <3.0.0
args >=1.4.0 <2.0.0 1.5.2
logging >=0.9.0 <0.12.0 0.11.3+2
package_config >=0.1.5 <2.0.0 1.0.5
path >=0.9.0 <2.0.0 1.6.2
stack_trace ^1.3.0 1.9.3
vm_service_client ^0.2.2+1 0.2.6+2
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
json_rpc_2 2.1.0
pub_semver 1.4.2
source_span 1.5.5
stream_channel 2.0.0
term_glyph 1.1.0
typed_data 1.1.6
web_socket_channel 1.0.13
Dev dependencies
test ^1.0.0