testreport 2.0.1 copy "testreport: ^2.0.1" to clipboard
testreport: ^2.0.1 copied to clipboard

This library can be used to process the results of dart tests. It processes data from the `json` output emitted by the dart test runner and provide an API to the test results.

example/example.dart

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

import 'package:testreport/testreport.dart';

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

  for (final suite in report.suites) {
    for (final test in suite.problems) {
      for (final problem in test.problems) {
        print('${suite.path} - ${test.name}: ${problem.message}');
      }
    }
  }
}

Future<Report> createReport(DateTime when, Stream<String> lines) async {
  var processor = Processor(timestamp: when);
  await for (final line in lines) {
    processor.process(json.decode(line) as Map<String, dynamic>);
  }
  return processor.report;
}
3
likes
160
points
200k
downloads

Publisher

unverified uploader

Weekly Downloads

This library can be used to process the results of dart tests. It processes data from the `json` output emitted by the dart test runner and provide an API to the test results.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on testreport