mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +01:00
Fix JUnit test-cases with error misclassified as passed test
Previous implementation considered only test-cases with <failure> as failed. This fix makes processing of <error> and <failure> the same. It also handles situation when error or failure elements contains only text and no attributes.
This commit is contained in:
parent
6969ae6af5
commit
d01ef000ba
4 changed files with 25 additions and 12 deletions
16
dist/index.js
generated
vendored
16
dist/index.js
generated
vendored
|
|
@ -930,18 +930,24 @@ class JavaJunitParser {
|
|||
});
|
||||
}
|
||||
getTestCaseResult(test) {
|
||||
if (test.failure)
|
||||
if (test.failure || test.error)
|
||||
return 'failed';
|
||||
if (test.skipped)
|
||||
return 'skipped';
|
||||
return 'success';
|
||||
}
|
||||
getTestCaseError(tc) {
|
||||
if (!this.options.parseErrors || !tc.failure) {
|
||||
var _a;
|
||||
if (!this.options.parseErrors) {
|
||||
return undefined;
|
||||
}
|
||||
const failure = tc.failure[0];
|
||||
const details = failure._;
|
||||
// We process <error> and <failure> the same way
|
||||
const failures = (_a = tc.failure) !== null && _a !== void 0 ? _a : tc.error;
|
||||
if (!failures) {
|
||||
return undefined;
|
||||
}
|
||||
const failure = failures[0];
|
||||
const details = typeof (failure) === 'object' ? failure._ : failure;
|
||||
let filePath;
|
||||
let line;
|
||||
const src = this.exceptionThrowSource(details);
|
||||
|
|
@ -953,7 +959,7 @@ class JavaJunitParser {
|
|||
path: filePath,
|
||||
line,
|
||||
details,
|
||||
message: failure.message
|
||||
message: typeof (failure) === 'object' ? failure.message : undefined
|
||||
};
|
||||
}
|
||||
exceptionThrowSource(stackTrace) {
|
||||
|
|
|
|||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
|
|
@ -107,18 +107,24 @@ export class JavaJunitParser implements TestParser {
|
|||
}
|
||||
|
||||
private getTestCaseResult(test: TestCase): TestExecutionResult {
|
||||
if (test.failure) return 'failed'
|
||||
if (test.failure || test.error) return 'failed'
|
||||
if (test.skipped) return 'skipped'
|
||||
return 'success'
|
||||
}
|
||||
|
||||
private getTestCaseError(tc: TestCase): TestCaseError | undefined {
|
||||
if (!this.options.parseErrors || !tc.failure) {
|
||||
if (!this.options.parseErrors) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const failure = tc.failure[0]
|
||||
const details = failure._
|
||||
// We process <error> and <failure> the same way
|
||||
const failures = tc.failure ?? tc.error
|
||||
if (!failures) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const failure = failures[0]
|
||||
const details = typeof failure === 'object' ? failure._ : failure
|
||||
let filePath
|
||||
let line
|
||||
|
||||
|
|
@ -132,7 +138,7 @@ export class JavaJunitParser implements TestParser {
|
|||
path: filePath,
|
||||
line,
|
||||
details,
|
||||
message: failure.message
|
||||
message: typeof failure === 'object' ? failure.message : undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ export interface TestCase {
|
|||
name: string
|
||||
time: string
|
||||
}
|
||||
failure?: Failure[]
|
||||
failure?: string | Failure[]
|
||||
error?: string | Failure[]
|
||||
skipped?: string[]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue