Merge pull request #118 from dorny/java-junit-support-errors

Fix JUnit test-cases with error misclassified as passed test
This commit is contained in:
Michal Dorner 2021-05-24 15:06:06 +02:00 committed by GitHub
commit e8f4fdfec7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 12 deletions

16
dist/index.js generated vendored
View file

@ -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

File diff suppressed because one or more lines are too long

View file

@ -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
}
}

View file

@ -33,7 +33,8 @@ export interface TestCase {
name: string
time: string
}
failure?: Failure[]
failure?: string | Failure[]
error?: string | Failure[]
skipped?: string[]
}