testreport 2.0.1 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.
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;
}