From cd212684938b47abfcb19e03f8cc337d3e639734 Mon Sep 17 00:00:00 2001 From: Michal Dorner Date: Sun, 18 Oct 2020 19:57:47 +0200 Subject: [PATCH] Add dart fixture project --- README.md | 5 +- __tests__/fixtures/dart-json.json | 33 +++ package.json | 3 +- reports/dart/.gitignore | 9 + reports/dart/analysis_options.yaml | 14 ++ reports/dart/lib/main.dart | 3 + reports/dart/pubspec.lock | 348 +++++++++++++++++++++++++++++ reports/dart/pubspec.yaml | 9 + reports/dart/test/main_test.dart | 31 +++ reports/dart/test/second_test.dart | 12 + 10 files changed, 464 insertions(+), 3 deletions(-) create mode 100644 __tests__/fixtures/dart-json.json create mode 100644 reports/dart/.gitignore create mode 100644 reports/dart/analysis_options.yaml create mode 100644 reports/dart/lib/main.dart create mode 100644 reports/dart/pubspec.lock create mode 100644 reports/dart/pubspec.yaml create mode 100644 reports/dart/test/main_test.dart create mode 100644 reports/dart/test/second_test.dart diff --git a/README.md b/README.md index aa44573..17156e2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Goal of this project is to create [Github Action](https://github.com/features/ac that could presents test results from popular testing frameworks as Github check run with code annotation in places where test failed. Support for following test reports are planned for initial release: -- [ ] dotnet-trx: [`dotnet test --logger trx`](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#examples) -- [ ] flutter-machine: `flutter test --machine` +- [ ] dotnet-trx: [`dotnet test --logger "trx;LogFileName=test-results.trx"`](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#examples) +- [ ] dart-json: [`dart test --file-reporter=\"json:test-results.json`](https://pub.dev/packages/test) +- [ ] flutter-machine: [`flutter test --machine > test-results.json`](https://flutter.dev/docs/cookbook/testing/unit/introduction) - [ ] jest-junit: [`jest --ci --reporters=jest-junit`](https://github.com/jest-community/jest-junit#readme) diff --git a/__tests__/fixtures/dart-json.json b/__tests__/fixtures/dart-json.json new file mode 100644 index 0000000..ab9d82c --- /dev/null +++ b/__tests__/fixtures/dart-json.json @@ -0,0 +1,33 @@ +{"protocolVersion":"0.1.1","runnerVersion":"1.15.4","pid":21728,"type":"start","time":0} +{"suite":{"id":0,"platform":"vm","path":"test\\main_test.dart"},"type":"suite","time":1} +{"test":{"id":1,"name":"loading test\\main_test.dart","suiteID":0,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":1} +{"suite":{"id":2,"platform":"vm","path":"test\\second_test.dart"},"type":"suite","time":12} +{"test":{"id":3,"name":"loading test\\second_test.dart","suiteID":2,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":12} +{"count":2,"type":"allSuites","time":13} +{"testID":3,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":3761} +{"group":{"id":4,"suiteID":2,"parentID":null,"name":null,"metadata":{"skip":false,"skipReason":null},"testCount":2,"line":null,"column":null,"url":null},"type":"group","time":3766} +{"test":{"id":5,"name":"Timeout test","suiteID":2,"groupIDs":[4],"metadata":{"skip":false,"skipReason":null},"line":5,"column":3,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/second_test.dart"},"type":"testStart","time":3767} +{"testID":1,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":3784} +{"group":{"id":6,"suiteID":0,"parentID":null,"name":null,"metadata":{"skip":false,"skipReason":null},"testCount":5,"line":null,"column":null,"url":null},"type":"group","time":3784} +{"group":{"id":7,"suiteID":0,"parentID":6,"name":"Test 1","metadata":{"skip":false,"skipReason":null},"testCount":3,"line":6,"column":3,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/main_test.dart"},"type":"group","time":3785} +{"test":{"id":8,"name":"Test 1 Passing test","suiteID":0,"groupIDs":[6,7],"metadata":{"skip":false,"skipReason":null},"line":7,"column":5,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/main_test.dart"},"type":"testStart","time":3785} +{"testID":5,"error":"TimeoutException after 0:00:00.000001: Test timed out after 0 seconds.","stackTrace":"dart:isolate _RawReceivePortImpl._handleMessage\n","isFailure":false,"type":"error","time":3804} +{"testID":5,"result":"error","skipped":false,"hidden":false,"type":"testDone","time":3804} +{"test":{"id":9,"name":"Skipped test","suiteID":2,"groupIDs":[4],"metadata":{"skip":true,"skipReason":"skipped test"},"line":9,"column":3,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/second_test.dart"},"type":"testStart","time":3805} +{"testID":9,"messageType":"skip","message":"Skip: skipped test","type":"print","time":3807} +{"testID":9,"result":"success","skipped":true,"hidden":false,"type":"testDone","time":3808} +{"testID":8,"result":"success","skipped":false,"hidden":false,"type":"testDone","time":3815} +{"group":{"id":10,"suiteID":0,"parentID":7,"name":"Test 1 Test 1.1","metadata":{"skip":false,"skipReason":null},"testCount":2,"line":11,"column":5,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/main_test.dart"},"type":"group","time":3817} +{"test":{"id":11,"name":"Test 1 Test 1.1 Failing test","suiteID":0,"groupIDs":[6,7,10],"metadata":{"skip":false,"skipReason":null},"line":12,"column":7,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/main_test.dart"},"type":"testStart","time":3817} +{"testID":11,"error":"Expected: <2>\n Actual: <1>\n","stackTrace":"package:test_api expect\ntest\\main_test.dart 13:9 main...\n","isFailure":true,"type":"error","time":3840} +{"testID":11,"result":"failure","skipped":false,"hidden":false,"type":"testDone","time":3840} +{"test":{"id":12,"name":"Test 1 Test 1.1 Exception in target unit","suiteID":0,"groupIDs":[6,7,10],"metadata":{"skip":false,"skipReason":null},"line":16,"column":7,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/main_test.dart"},"type":"testStart","time":3845} +{"testID":12,"error":"Exception: Some error","stackTrace":"package:darttest/main.dart 2:3 throwError\ntest\\main_test.dart 17:9 main...\n","isFailure":false,"type":"error","time":3852} +{"testID":12,"result":"error","skipped":false,"hidden":false,"type":"testDone","time":3853} +{"group":{"id":13,"suiteID":0,"parentID":6,"name":"Test 2","metadata":{"skip":false,"skipReason":null},"testCount":2,"line":22,"column":3,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/main_test.dart"},"type":"group","time":3854} +{"test":{"id":14,"name":"Test 2 Exception in test","suiteID":0,"groupIDs":[6,13],"metadata":{"skip":false,"skipReason":null},"line":23,"column":5,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/main_test.dart"},"type":"testStart","time":3854} +{"testID":14,"error":"Exception: Some error","stackTrace":"test\\main_test.dart 24:7 main..\n","isFailure":false,"type":"error","time":3869} +{"testID":14,"result":"error","skipped":false,"hidden":false,"type":"testDone","time":3869} +{"test":{"id":15,"name":"Test 2 Timeout test","suiteID":0,"groupIDs":[6,13],"metadata":{"skip":false,"skipReason":null},"line":27,"column":5,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/main_test.dart"},"type":"testStart","time":3870} +{"testID":15,"result":"success","skipped":false,"hidden":false,"type":"testDone","time":3882} +{"success":false,"type":"done","time":3886} diff --git a/package.json b/package.json index 7479dc3..39f7679 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "package": "ncc build --source-map --license licenses.txt", "test": "jest", "all": "npm run build && npm run format && npm run lint && npm run package && npm test", - "dotnet-fixture": "dotnet test reports/dotnet/DotnetTests.XUnitTests --logger \"trx;LogFileName=../../../../__tests__/fixtures/dotnet-trx.trx\"" + "dotnet-fixture": "dotnet test reports/dotnet/DotnetTests.XUnitTests --logger \"trx;LogFileName=../../../../__tests__/fixtures/dotnet-trx.trx\"", + "dart-fixture": "cd \"reports/dart\" && dart test --file-reporter=\"json:../../__tests__/fixtures/dart-json.json\"" }, "repository": { "type": "git", diff --git a/reports/dart/.gitignore b/reports/dart/.gitignore new file mode 100644 index 0000000..3d64647 --- /dev/null +++ b/reports/dart/.gitignore @@ -0,0 +1,9 @@ +# Files and directories created by pub +.dart_tool/ +.packages + +# Conventional directory for build outputs +build/ + +# Directory created by dartdoc +doc/api/ diff --git a/reports/dart/analysis_options.yaml b/reports/dart/analysis_options.yaml new file mode 100644 index 0000000..a686c1b --- /dev/null +++ b/reports/dart/analysis_options.yaml @@ -0,0 +1,14 @@ +# Defines a default set of lint rules enforced for +# projects at Google. For details and rationale, +# see https://github.com/dart-lang/pedantic#enabled-lints. +include: package:pedantic/analysis_options.yaml + +# For lint rules and documentation, see http://dart-lang.github.io/linter/lints. +# Uncomment to specify additional rules. +# linter: +# rules: +# - camel_case_types + +analyzer: +# exclude: +# - path/to/excluded/files/** diff --git a/reports/dart/lib/main.dart b/reports/dart/lib/main.dart new file mode 100644 index 0000000..922c25a --- /dev/null +++ b/reports/dart/lib/main.dart @@ -0,0 +1,3 @@ +void throwError() { + throw Exception('Some error'); +} diff --git a/reports/dart/pubspec.lock b/reports/dart/pubspec.lock new file mode 100644 index 0000000..882993d --- /dev/null +++ b/reports/dart/pubspec.lock @@ -0,0 +1,348 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "11.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "0.40.4" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.0" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.2" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.3" + cli_util: + dependency: transitive + description: + name: cli_util + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.14.13" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + coverage: + dependency: transitive + description: + name: coverage + url: "https://pub.dartlang.org" + source: hosted + version: "0.14.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.5" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.2" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.4" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.4" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.2" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "0.11.4" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.9" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.3" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.7" + node_interop: + dependency: transitive + description: + name: node_interop + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + node_io: + dependency: transitive + description: + name: node_io + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + node_preamble: + dependency: transitive + description: + name: node_preamble + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.12" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.3" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + pedantic: + dependency: "direct dev" + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.2" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.4" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.9" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + shelf_static: + dependency: transitive + description: + name: shelf_static + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.8" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.3" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + source_maps: + dependency: transitive + description: + name: source_maps + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.9" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.5" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + test: + dependency: "direct dev" + description: + name: test + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.4" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.18" + test_core: + dependency: transitive + description: + name: test_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.11+1" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.0" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.7+15" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.3" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1" +sdks: + dart: ">=2.8.1 <3.0.0" diff --git a/reports/dart/pubspec.yaml b/reports/dart/pubspec.yaml new file mode 100644 index 0000000..860687f --- /dev/null +++ b/reports/dart/pubspec.yaml @@ -0,0 +1,9 @@ +name: darttest +description: A simple command-line application. + +environment: + sdk: '>=2.8.1 <3.0.0' + +dev_dependencies: + pedantic: ^1.9.0 + test: ^1.15.4 diff --git a/reports/dart/test/main_test.dart b/reports/dart/test/main_test.dart new file mode 100644 index 0000000..a90f873 --- /dev/null +++ b/reports/dart/test/main_test.dart @@ -0,0 +1,31 @@ +import 'package:darttest/main.dart'; +import 'package:test/test.dart'; +import 'dart:io'; + +void main() { + group('Test 1', () { + test('Passing test', () { + expect(1, equals(1)); + }); + + group('Test 1.1', () { + test('Failing test', () { + expect(1, equals(2)); + }); + + test('Exception in target unit', () { + throwError(); + }); + }); + }); + + group('Test 2', () { + test('Exception in test', () { + throw Exception('Some error'); + }); + + test('Timeout test', () { + sleep(Duration(milliseconds: 1)); + }, timeout: Timeout(Duration(microseconds: 1))); + }); +} diff --git a/reports/dart/test/second_test.dart b/reports/dart/test/second_test.dart new file mode 100644 index 0000000..bc68571 --- /dev/null +++ b/reports/dart/test/second_test.dart @@ -0,0 +1,12 @@ +import 'dart:async'; +import 'package:test/test.dart'; + +void main() { + test('Timeout test', () async { + await Future.delayed(const Duration(seconds: 1)); + }, timeout: Timeout(Duration(microseconds: 1))); + + test('Skipped test', () { + // do nothing + }, skip: 'skipped test'); +}