Compare commits

...

7 Commits

Author SHA1 Message Date
Michal Dorner
6969ae6af5 Update CHANGELOG for v1.4.3 2021-05-13 23:01:52 +02:00
Michal Dorner
7c6c7df048 Remove depandabot - for this project its too annoying without real benefits 2021-05-13 23:00:15 +02:00
Michal Dorner
0ed324d155 Merge pull request #115 from dorny/java-junit-handle-missing-time
Patch java-junit to handle missing time field
2021-05-13 22:53:51 +02:00
Michal Dorner
72c193c336 Patch java-junit to handle missing time field
Normally a <testsuites> element has a time field. In some JUnit implementations this field is missing. This issue was found in junit XML created in matlab.

At the moment I don't plan to explicitly support matlab - that would require to add more tests and documentation. However this patch should make it work with the existing java-junit parser.
2021-05-13 22:39:52 +02:00
Michal Dorner
e873f73dd6 Merge pull request #114 from dorny/issue-113-print-breaks-dart-parsing
Fix dart-json parsing broken by print message
2021-05-13 22:04:27 +02:00
Michal Dorner
f88270a385 Update dist/index.js 2021-05-13 21:56:10 +02:00
Michal Dorner
dcaab46b46 Fix dart-json parsing broken by print message
Print message related to suite, instead of a specific test, would break parsing - it would expect test object to be present in dictionary but there would be none.
This fix adds necessary check and messages not related to tracked tests will be ignored.
2021-05-13 21:48:55 +02:00
8 changed files with 23 additions and 24 deletions

View File

@@ -1,11 +0,0 @@
version: 2
updates:
# Enable version updates for npm
- package-ecosystem: 'npm'
# Look for `package.json` and `lock` files in the `root` directory
directory: '/'
# Check the npm registry for updates every day (weekdays)
schedule:
interval: 'monthly'
ignore:
- dependency-name: '@types/node'

View File

@@ -1,5 +1,9 @@
# Changelog # Changelog
## v1.4.3
- [Patch java-junit to handle missing time field](https://github.com/dorny/test-reporter/pull/115)
- [Fix dart-json parsing broken by print message](https://github.com/dorny/test-reporter/pull/114)
## v1.4.2 ## v1.4.2
- [Fix dotnet-trx parsing of passed tests with non-empty error info](https://github.com/dorny/test-reporter/commit/43d89d5ee509bcef7bd0287aacc0c4a4fb9c1657) - [Fix dotnet-trx parsing of passed tests with non-empty error info](https://github.com/dorny/test-reporter/commit/43d89d5ee509bcef7bd0287aacc0c4a4fb9c1657)

View File

@@ -4,6 +4,7 @@
{"suite":{"id":2,"platform":"vm","path":"test\\second_test.dart"},"type":"suite","time":11} {"suite":{"id":2,"platform":"vm","path":"test\\second_test.dart"},"type":"suite","time":11}
{"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":11} {"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":11}
{"count":2,"type":"allSuites","time":11} {"count":2,"type":"allSuites","time":11}
{"testID":1,"messageType":"print","message":"Hello from the test","type":"print","time":3828}
{"testID":3,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":3649} {"testID":3,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":3649}
{"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":3654} {"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":3654}
{"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":3655} {"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":3655}

18
dist/index.js generated vendored
View File

@@ -483,13 +483,13 @@ class DartJsonParser {
group.tests.push(test); group.tests.push(test);
tests[evt.test.id] = test; tests[evt.test.id] = test;
} }
else if (dart_json_types_1.isTestDoneEvent(evt) && !evt.hidden) { else if (dart_json_types_1.isTestDoneEvent(evt) && !evt.hidden && tests[evt.testID]) {
tests[evt.testID].testDone = evt; tests[evt.testID].testDone = evt;
} }
else if (dart_json_types_1.isErrorEvent(evt)) { else if (dart_json_types_1.isErrorEvent(evt) && tests[evt.testID]) {
tests[evt.testID].error = evt; tests[evt.testID].error = evt;
} }
else if (dart_json_types_1.isMessageEvent(evt)) { else if (dart_json_types_1.isMessageEvent(evt) && tests[evt.testID]) {
tests[evt.testID].print.push(evt); tests[evt.testID].print.push(evt);
} }
else if (dart_json_types_1.isDoneEvent(evt)) { else if (dart_json_types_1.isDoneEvent(evt)) {
@@ -763,10 +763,10 @@ class DotnetTrxParser {
return undefined; return undefined;
} }
const error = test.error; const error = test.error;
if (!Array.isArray(error.Message) if (!Array.isArray(error.Message) ||
|| error.Message.length === 0 error.Message.length === 0 ||
|| !Array.isArray(error.StackTrace) !Array.isArray(error.StackTrace) ||
|| error.StackTrace.length === 0) { error.StackTrace.length === 0) {
return undefined; return undefined;
} }
const message = test.error.Message[0]; const message = test.error.Message[0];
@@ -888,6 +888,7 @@ class JavaJunitParser {
} }
} }
getTestRunResult(filePath, junit) { getTestRunResult(filePath, junit) {
var _a;
const suites = junit.testsuites.testsuite === undefined const suites = junit.testsuites.testsuite === undefined
? [] ? []
: junit.testsuites.testsuite.map(ts => { : junit.testsuites.testsuite.map(ts => {
@@ -896,7 +897,8 @@ class JavaJunitParser {
const sr = new test_results_1.TestSuiteResult(name, this.getGroups(ts), time); const sr = new test_results_1.TestSuiteResult(name, this.getGroups(ts), time);
return sr; return sr;
}); });
const time = parseFloat(junit.testsuites.$.time) * 1000; const seconds = parseFloat((_a = junit.testsuites.$) === null || _a === void 0 ? void 0 : _a.time);
const time = isNaN(seconds) ? undefined : seconds * 1000;
return new test_results_1.TestRunResult(filePath, suites, time); return new test_results_1.TestRunResult(filePath, suites, time);
} }
getGroups(suite) { getGroups(suite) {

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -24,4 +24,6 @@ void main() {
throw Exception('Some error'); throw Exception('Some error');
}); });
}); });
print('Hello from the test');
} }

View File

@@ -114,11 +114,11 @@ export class DartJsonParser implements TestParser {
const group = suite.groups[evt.test.groupIDs[evt.test.groupIDs.length - 1]] const group = suite.groups[evt.test.groupIDs[evt.test.groupIDs.length - 1]]
group.tests.push(test) group.tests.push(test)
tests[evt.test.id] = test tests[evt.test.id] = test
} else if (isTestDoneEvent(evt) && !evt.hidden) { } else if (isTestDoneEvent(evt) && !evt.hidden && tests[evt.testID]) {
tests[evt.testID].testDone = evt tests[evt.testID].testDone = evt
} else if (isErrorEvent(evt)) { } else if (isErrorEvent(evt) && tests[evt.testID]) {
tests[evt.testID].error = evt tests[evt.testID].error = evt
} else if (isMessageEvent(evt)) { } else if (isMessageEvent(evt) && tests[evt.testID]) {
tests[evt.testID].print.push(evt) tests[evt.testID].print.push(evt)
} else if (isDoneEvent(evt)) { } else if (isDoneEvent(evt)) {
success = evt.success success = evt.success

View File

@@ -70,7 +70,8 @@ export class JavaJunitParser implements TestParser {
return sr return sr
}) })
const time = parseFloat(junit.testsuites.$.time) * 1000 const seconds = parseFloat(junit.testsuites.$?.time)
const time = isNaN(seconds) ? undefined : seconds * 1000
return new TestRunResult(filePath, suites, time) return new TestRunResult(filePath, suites, time)
} }