test_coverage 0.2.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • new48

test_coverage Build Status

A simple command-line tool to collect test coverage information from Dart VM tests. It is useful if you need to generate coverage reports locally during development.

Usage

Add dev dependency to your pubspec.yaml:

dev_dependencies:
  test_coverage: ^0.1.0

Run pub get to install. Then, in the root of your project run:

pub run test_coverage

Result is saved in coverage/lcov.info. If you have lcov tool installed on your system (for Mac it's brew install lcov) you can generate coverage reports using genhtml command:

genhtml -o coverage coverage/lcov.info
# Open in the default browser (mac):
open coverage/index.html

Integrations

Resulting coverage/lcov.info file is ready to be consumed by Codecov command-line tool, so no extra step is needed.

This library was not tested with coveralls yet.

Known limitations

  • This library was created to run Dart VM tests. It has not been tested and likely won't work for Dart code targeting web platform (compiled to JavaScript). There is no need to use this tool for Flutter as it allows collecting coverage information with flutter test --coverage.

How it works

The tool performs following steps:

1. Generates test/.test_coverage.dart file which is essentially a "test all" script.

It is recommended to add this file to your .gitignore.

Below is an example of test/.test_coverage.dart:

// Auto-generated by test_coverage. Do not edit by hand.
// Consider adding this file to your .gitignore.

import 'some_test.dart' as some_test;
import 'nested/other_test.dart' as other_test;
import 'some_other_test.dart' as some_other_test;
void main() {
  some_test.main();
  other_test.main();
  some_other_test.main();
}

2. Runs the tests

Following command is used to run the tests:

dart --pause-isolates-on-exit --enable_asserts --enable-vm-service \
  test/.test_coverage.dart

3. Collects and formats coverage information

When test execution is completed the tool uses functionality of the coverage package to collect and format coverage report.

Feel free to file feature requests and bug reports at the issue tracker.

0.2.2

  • Renamed coverage/coverage.lcov to coverage/lcov.info.

0.2.1

  • Generate coverage badge in coverage/badge.svg.

0.2.0

  • Moved generated reports to coverage/ subfolder.
  • Added tests.
  • Updated usage instructions to recommend local dev_dependencies and pub run test_coverage instead of global installation.

0.1.1

  • Make paths in lcov file relative to the project root.

0.1.0

  • Initial version

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate test_coverage

2. Use it

The package has the following executables:


$ test_coverage

Use this package as a library

1. Depend on it

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


dependencies:
  test_coverage: ^0.2.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:test_coverage/test_coverage.dart';
  
Version Uploaded Documentation Archive
0.2.2 Jul 10, 2018 Go to the documentation of test_coverage 0.2.2 Download test_coverage 0.2.2 archive
0.2.1 Jul 10, 2018 Go to the documentation of test_coverage 0.2.1 Download test_coverage 0.2.1 archive
0.2.0 Jul 9, 2018 Go to the documentation of test_coverage 0.2.0 Download test_coverage 0.2.0 archive
0.1.1 Jun 29, 2018 Go to the documentation of test_coverage 0.1.1 Download test_coverage 0.1.1 archive
0.1.0 Jun 29, 2018 Go to the documentation of test_coverage 0.1.0 Download test_coverage 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
8
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
72
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.66.0
  • pana: 0.11.7

Platforms

Detected platforms: Flutter, other

Primary library: package:test_coverage/test_coverage.dart with components: io, isolate.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Running dartdoc failed.

Make sure dartdoc runs without any issues.

The description is too short.

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Maintain an example.

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use test_coverage.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.66.0 <2.0.0
coverage ^0.12.1 0.12.1
lcov ^4.1.0 4.1.0
path ^1.6.1 1.6.1
Transitive dependencies
args 1.4.3
async 2.0.7
charcode 1.1.2
collection 1.14.10
convert 2.0.1
crypto 2.0.5
json_rpc_2 2.0.8
logging 0.11.3+1
package_config 1.0.3
pub_semver 1.4.1
source_span 1.4.0
stack_trace 1.9.2
stream_channel 1.6.7+1
typed_data 1.1.5
vm_service_client 0.2.5
web_socket_channel 1.0.8
Dev dependencies
test ^1.0.0