test_report_parser 1.2.1 copy "test_report_parser: ^1.2.1" to clipboard
test_report_parser: ^1.2.1 copied to clipboard

This library contains an auto-generated Dart Model representing the events emitted by the Dart Tests JSON reporter.

example/test_report_parser_example.dart

import 'package:test_report_parser/test_report_parser.dart';

const logExample = r'''
{"protocolVersion":"0.1.1","runnerVersion":"1.16.8","pid":45879,"type":"start","time":0}
{"suite":{"id":0,"platform":"vm","path":"test/io_test.dart"},"type":"suite","time":0}
{"test":{"id":1,"name":"loading test/io_test.dart","suiteID":0,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":2}
{"suite":{"id":2,"platform":"vm","path":"test/cache_test.dart"},"type":"suite","time":16}
{"success":true,"type":"done","time":36361}
''';

void main() {
  for (final line in logExample.split('\n').where((l) => l.isNotEmpty)) {
    final event = parseJsonToEvent(line);
    print(event);

    // check specific events
    if (event is TestStartEvent) {
      print('=== Test "${event.test.name}" has started. ===');
    }
    if (event is DoneEvent) {
      final ok = event.success;
      if (ok == null) {
        print('Tests did not terminate correctly');
      } else if (ok) {
        print('!!!!!! Tests were successful !!!!!!');
      } else {
        print('XXXXXX There were failures. XXXXXX');
      }
    }
  }
}
0
likes
130
pub points
49%
popularity

Publisher

unverified uploader

This library contains an auto-generated Dart Model representing the events emitted by the Dart Tests JSON reporter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

path

More

Packages that depend on test_report_parser