Skip to content

Commit

Permalink
Patch java-junit to handle missing time field
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Michal Dorner committed May 13, 2021
1 parent e873f73 commit 72c193c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion 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.

3 changes: 2 additions & 1 deletion src/parsers/java-junit/java-junit-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export class JavaJunitParser implements TestParser {
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)
}

Expand Down

0 comments on commit 72c193c

Please sign in to comment.