lcov 3.1.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 49

LCOV Reports for Dart

Runtime Release License Coverage Build

Parse and format LCOV coverage reports, in Dart.

Requirements

The latest Dart SDK and Pub versions. If you plan to play with the sources, you will also need the latest Grinder version.

Installing via Pub

1. Depend on it

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

dependencies:
  lcov: *

2. Install it

Install this package and its dependencies from a command prompt:

$ pub get

3. Import it

Now in your Dart code, you can use:

import 'package:lcov/lcov.dart';

Usage

This package provides a set of classes representing a coverage report and its data. The Report class, the main one, provides the parsing and formatting features.

Parse coverage data from a LCOV file

The Report.fromCoverage() constructor parses a coverage report provided as string, and creates a Report instance giving detailed information about this coverage report:

try {
  var coverage = await new File('lcov.info').readAsString();
  var report = new Report.fromCoverage(coverage);
  print('The coverage report contains ${report.records.length} records:');
  print(report.toJson());
}

on FormatException {
  print('The LCOV report has an invalid format.');
}

The Report.toJson() instance method will return a map like this:

{
  "testName": "Example",
  "records": [
    {
      "sourceFile": "/home/cedx/lcov.dart/fixture.dart",
      "branches": {
        "found": 0,
        "hit": 0,
        "data": []
      },
      "functions": {
        "found": 1,
        "hit": 1,
        "data": [
          {"functionName": "main", "lineNumber": 4, "executionCount": 2}
        ]
      },
      "lines": {
        "found": 2,
        "hit": 2,
        "data": [
          {"lineNumber": 6, "executionCount": 2, "checksum": "PF4Rz2r7RTliO9u6bZ7h6g"},
          {"lineNumber": 9, "executionCount": 2, "checksum": "y7GE3Y4FyXCeXcrtqgSVzw"}
        ]
      }
    }
  ]
}

Format coverage data to the LCOV format

Each provided class has a dedicated toString() instance method returning the corresponding data formatted as LCOV string. All you have to do is to create the adequate structure using these different classes, and to export the final result:

var lineCoverage = new LineCoverage(2, 2, [
  new LineData(6, executionCount: 2, checksum: 'PF4Rz2r7RTliO9u6bZ7h6g'),
  new LineData(7, executionCount: 2, checksum: 'yGMB6FhEEAd8OyASe3Ni1w')
]);

var record = new Record('/home/cedx/lcov.dart/fixture.dart')
  ..functions = new FunctionCoverage(1, 1)
  ..lines = lineCoverage;

var report = new Report('Example', [record]);
print(report);

The Report.toString() method will return a LCOV report formatted like this:

TN:Example
SF:/home/cedx/lcov.dart/fixture.dart
FNF:1
FNH:1
DA:6,2,PF4Rz2r7RTliO9u6bZ7h6g
DA:7,2,yGMB6FhEEAd8OyASe3Ni1w
LF:2
LH:2
end_of_record

See also

License

LCOV Reports for Dart is distributed under the MIT License.

Changelog

This file contains highlights of what changes on each version of the LCOV Reports for Dart project.

Version 3.1.0

  • Updated the package dependencies.

Version 3.0.0

  • Breaking change: changed the signature of most constructors.
  • Breaking change: most properties of data classes are now final.

Version 2.1.0

Version 2.0.1

  • Fixed a bug: a parsing error occurs when the coverage data does not include a test name.

Version 2.0.0

  • Breaking change: changed the Report.parse() static method to the fromCoverage constructor.
  • Breaking change: raised the required Dart version.
  • Updated the package dependencies.

Version 1.0.0

  • First stable release.

Version 0.4.0

  • Breaking change: raised the required Dart version.
  • Updated the package dependencies.

Version 0.3.1

  • Fixed a bug in Report.parse() method.

Version 0.3.0

  • Added the data parameter to the default constructors of the coverage classes.
  • Added the records parameter to the default constructor of the Report class.

Version 0.2.0

  • Breaking change: changed the signature of most default constructors.
  • Empty test names are not included in the report output.

Version 0.1.0

  • Initial release.

1. Depend on it

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


dependencies:
  lcov: "^3.1.0"

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 packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:lcov/lcov.dart';
        
Version Uploaded Documentation Archive
3.1.0 Nov 3, 2017 Go to the documentation of lcov 3.1.0 Download lcov 3.1.0 archive
3.0.0 Sep 13, 2017 Go to the documentation of lcov 3.0.0 Download lcov 3.0.0 archive
2.1.0 Sep 9, 2017 Go to the documentation of lcov 2.1.0 Download lcov 2.1.0 archive
2.0.1 Aug 8, 2017 Go to the documentation of lcov 2.0.1 Download lcov 2.0.1 archive
2.0.0 Jul 30, 2017 Go to the documentation of lcov 2.0.0 Download lcov 2.0.0 archive
1.0.0 Mar 25, 2017 Go to the documentation of lcov 1.0.0 Download lcov 1.0.0 archive
0.4.0 Feb 18, 2017 Go to the documentation of lcov 0.4.0 Download lcov 0.4.0 archive
0.3.1 Feb 11, 2017 Go to the documentation of lcov 0.3.1 Download lcov 0.3.1 archive
0.3.0 Jan 22, 2017 Go to the documentation of lcov 0.3.0 Download lcov 0.3.0 archive
0.2.0 Jan 22, 2017 Go to the documentation of lcov 0.2.0 Download lcov 0.2.0 archive

All 11 versions...

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
97 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
49

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:lcov/lcov.dart.

Suggestions

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

  • 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 lcov.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
Dev dependencies
coverage ^0.9.3
grinder ^0.8.0
test ^0.12.27