testreport 1.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

Test Report #

Introduction #

This library can be used to process the results of dart tests.

The goal of this library is to process the data from the json output emitted by the dart test runner and provide an API to the interpreted test results.

Purpose #

By running

pub run test simple_test.dart --reporter json

and the contents of simple_test.dart is

import 'package:test/test.dart';

main() {
  test('simple', () {
    expect(true, true);

the dart test runner will output the results of the test in json format as a stream of events:

{"test":{"id":1,"name":"loading simple_test.dart","suiteID":0,"groupIDs":[],"metadata":{"skip":false,"skipReason":null}},"type":"testStart","time":0}

From this json output, it is not easy to see how many tests were executed, how many failed and how much time was spent in each test.

The Processor in this project takes the json events, and turns them into a Report, that is suitable for further processing.

License and contributors #

1.2.0 #

  • require dart 2.7+
  • support (ignore) debug events

1.1.0 #

  • require dart 2.3+

1.0.0 #

  • drop support for Dart 1.x

0.3.1 #

  • dart 2.0 support

0.3.0 #

  • remove dependency on built_collection

0.2.0 #

  • moved part files to src/api and implementation files to src/impl

0.1.0 #

  • Initial implementation


import 'dart:io';
import 'dart:convert';

import 'package:testreport/testreport.dart';

void main(List<String> args) async {
  var file = File(args[0]);
  var lines = LineSplitter().bind(utf8.decoder.bind(file.openRead()));
  var report = await createReport(file.lastModifiedSync(), lines);

  report.suites.forEach((s) {
    s.problems.forEach((t) {
      t.problems.forEach((p) {
        print('${s.path} - ${t.name}: ${p.message}');

Future<Report> createReport(DateTime when, Stream<String> lines) async {
  var processor = Processor(timestamp: when);
  await for (String line in lines) {
    processor.process(json.decode(line) as Map<String, dynamic>);
  return processor.report;

Use this package as a library

1. Depend on it

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

  testreport: ^1.2.0

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:testreport/testreport.dart';
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 Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
pedantic ^1.9.0
test any