Merge pull request #399 from AnthonyBarbier/fix_junit_message

This commit is contained in:
Jozef Izso 2024-06-25 14:48:32 +02:00 committed by GitHub
commit 3c93b151a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 25 additions and 8 deletions

View file

@ -10,4 +10,5 @@ AcmeLibTests.AcmeLibTests
✅ test_always_pass ✅ test_always_pass
✅ test_always_skip ✅ test_always_skip
❌ test_always_fail ❌ test_always_fail
failed
``` ```

View file

@ -41,7 +41,7 @@ at java.lang.Thread.run(Thread.java:748)
", ",
"line": 29, "line": 29,
"message": undefined, "message": "java.lang.AssertionError: expected [1.2.1] but found [1.2.0]",
"path": "pulsar-common/src/test/java/org/apache/pulsar/AddMissingPatchVersionTest.java", "path": "pulsar-common/src/test/java/org/apache/pulsar/AddMissingPatchVersionTest.java",
}, },
"name": "testVersionStrings", "name": "testVersionStrings",
@ -100,7 +100,7 @@ at java.lang.Thread.run(Thread.java:748)
", ",
"line": 29, "line": 29,
"message": undefined, "message": "java.lang.AssertionError: expected [1.2.1] but found [1.2.0]",
"path": "pulsar-common/src/test/java/org/apache/pulsar/AddMissingPatchVersionTest.java", "path": "pulsar-common/src/test/java/org/apache/pulsar/AddMissingPatchVersionTest.java",
}, },
"name": "testVersionStrings", "name": "testVersionStrings",

View file

@ -25,7 +25,7 @@ TestRunResult {
"error": { "error": {
"details": undefined, "details": undefined,
"line": undefined, "line": undefined,
"message": undefined, "message": "failed",
"path": undefined, "path": undefined,
}, },
"name": "test_always_fail", "name": "test_always_fail",

11
dist/index.js generated vendored
View file

@ -1178,7 +1178,7 @@ class JavaJunitParser {
return 'success'; return 'success';
} }
getTestCaseError(tc) { getTestCaseError(tc) {
var _a; var _a, _b;
if (!this.options.parseErrors) { if (!this.options.parseErrors) {
return undefined; return undefined;
} }
@ -1198,11 +1198,18 @@ class JavaJunitParser {
line = src.line; line = src.line;
} }
} }
let message;
if (typeof failure === 'object') {
message = failure.$.message;
if ((_b = failure.$) === null || _b === void 0 ? void 0 : _b.type) {
message = failure.$.type + ': ' + message;
}
}
return { return {
path: filePath, path: filePath,
line, line,
details, details,
message: typeof failure === 'object' ? failure.message : undefined message
}; };
} }
exceptionThrowSource(stackTrace) { exceptionThrowSource(stackTrace) {

View file

@ -137,11 +137,18 @@ export class JavaJunitParser implements TestParser {
} }
} }
let message
if (typeof failure === 'object') {
message = failure.$.message
if (failure.$?.type) {
message = failure.$.type + ': ' + message
}
}
return { return {
path: filePath, path: filePath,
line, line,
details, details,
message: typeof failure === 'object' ? failure.message : undefined message
} }
} }

View file

@ -40,6 +40,8 @@ export interface TestCase {
export interface Failure { export interface Failure {
_: string _: string
type: string $: {
message: string type?: string
message: string
}
} }