Skip to content

Commit

Permalink
Merge pull request #118 from dorny/java-junit-support-errors
Browse files Browse the repository at this point in the history
Fix JUnit test-cases with error misclassified as passed test
  • Loading branch information
Michal Dorner authored and GitHub committed May 24, 2021
2 parents 6969ae6 + d01ef00 commit e8f4fdf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
16 changes: 11 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions src/parsers/java-junit/java-junit-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -132,7 +138,7 @@ export class JavaJunitParser implements TestParser {
path: filePath,
line,
details,
message: failure.message
message: typeof failure === 'object' ? failure.message : undefined
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/parsers/java-junit/java-junit-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export interface TestCase {
name: string
time: string
}
failure?: Failure[]
failure?: string | Failure[]
error?: string | Failure[]
skipped?: string[]
}

Expand Down

0 comments on commit e8f4fdf

Please sign in to comment.