dorny / test-reporter

Displays test results from popular testing frameworks directly in GitHub
MIT License
801 stars 200 forks source link

Error: TypeError: Cannot read properties of undefined (reading 'split') when <failure> element has no value #239

Open akomakom opened 1 year ago

akomakom commented 1 year ago

I am generating junit xml using golang and github.com/jstemmer/go-junit-report/v2@latest. Sometimes, on failure, it produces XML with an empty failure element. This produces a parse error:

Run dorny/test-reporter@v1
Action was triggered by pull_request: using SHA from head of source branch
...
Using test report parser 'java-junit'
Creating test report XXXX
  Processing test results for check run XXXX
  Creating check run XXXX
  Creating report summary
  Generating check run summary
Error: TypeError: Cannot read properties of undefined (reading 'split')

Sample XML:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="1">
    <testsuite name="my.company.com/suite/e2e/node_scale" tests="1" failures="1" errors="0" id="9"
               hostname="some-hostname.com" time="341.455" timestamp="2023-03-17T21:23:52Z">
        <testcase name="TestNodeScale" classname="my.company.com/e2e/node_scale" time="341.340">
            <failure message="Failed"></failure>
        </testcase>
    </testsuite>
</testsuites>

Adding a value, eg <failure message="Failed">bla</failure resolves this issue. I do not know if empty element is valid in junit format. If it is not valid, then I should open an issue with github.com/jstemmer/go-junit-report.

My action:

      - name: Publish Test Report
        uses: dorny/test-reporter@v1
        if: success() || failure()
        with:
          name: Junit Publish Test
          path: junit-sample.xml
          reporter: java-junit
ThorntonMatthewD commented 1 year ago

I am experiencing this same issue, except with XML output from rspec_junit_formatter.

Run dorny/test-reporter@v1
Check runs will be created with SHA=XXX
> Listing all files tracked by git
Found 4538 files tracked by GitHub
Using test report parser 'java-junit'
> Creating test report Rspec Test Results
  Processing test results for check run Rspec Test Results
  Creating check run My Awesone Test
  Creating report summary
  Generating check run summary
  Creating annotations
Error: TypeError: Cannot read properties of undefined (reading 'split')

My failure does occur further along in, however, in the Creating annotations step. Since we've used the same reporter, it may be something to do with the parser which results in:

https://github.com/dorny/test-reporter/blob/e9fa2f582c0ebbe2e263fd18fad744d52e0b0203/src/report/get-annotations.ts#L59

err.details === undefined
YevheniiaSilbernagl commented 1 year ago

I'm having a similar issue parsing junit report format from dependency-check/Dependency-Check_Action