Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'split' of undefined #137

Closed
LaPeste opened this issue Sep 2, 2021 · 4 comments · Fixed by #213
Closed

Cannot read property 'split' of undefined #137

LaPeste opened this issue Sep 2, 2021 · 4 comments · Fixed by #213

Comments

@LaPeste
Copy link

LaPeste commented Sep 2, 2021

I get ##[error]Cannot read property 'split' of undefined when parsing test results with the java-junit reporter.
I looked at the code of the action and I understand that the error comes from parsing the content of the file. Unfortunately, it's hard for me to pinpoint exactly where that's happening as there's no stacktrace and there's a huge try/catch in main.
I looked at the split calls used in the code, and I'd be tempted to say that the issue could be around parsing the stacktrace of the failing tests. However, the same test failures are happening in other platforms and there the action works just fine. I have this failure only in tests run on UWP.
This is the test run where the issue appears.
I'm using version 1.5.0 because of the nice addition of path-replace-backslashes. If you believe that this error could have been introduced by this latest version, I can try to convert the backslashes myself and try 1.4.x .

@LaPeste
Copy link
Author

LaPeste commented Sep 9, 2021

I spent the time to go through it and the problem was in the fact that some of our test results had an empty <failure message=" Expected: True; But was: False;"></failure>. This is not accounted for by the action and so it crashes here. And a few other places where the failure tag is always assumed to have content.
We're going to look into our test report to understand why we have some empty <failure>s, but I don't know if the failure tag should ever be expected to be null. If you think it should I can put up a PR. Let me know.

@JimLewis
Copy link

JimLewis commented Dec 3, 2021

Great reporter, however, we are running into this issue too. From the different reports I have seen, many reporters generate failure message of the form:
<failure message=" Expected: True; But was: False;" /.>

Is this not permitted here? Do you have a schema for the XML you accept, expect, and/or test against?

@DanaGoyette
Copy link

DanaGoyette commented Feb 4, 2022

For my uses (a customized version of mocha-junit-reporter to fix bugs with suite nesting), and when I tried using the jest-junit parser out of curiosity, it died with the same split error. In my case, java-junit at least works.

I also tried mocha-junit, but that fails on trying to call startsWith on undefined.

It would be far easier to debug if the tool logged what it was trying to parse when it died, and showed a backtrace!

@dkirrane
Copy link

hitting this with the below test results xml file Error: Cannot read property 'split' of undefined

- name: Test Report
  uses: dorny/test-reporter@v1
  with:
    name: Terratest Tests
    path: report.xml
    reporter: java-junit

report.xml

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
	<testsuite tests="1" failures="1" time="0.000" name="elvis">
		<properties>
			<property name="go.version" value="go1.17"></property>
		</properties>
		<testcase classname="elvis" name="[build failed]" time="0.000">
			<failure message="Failed" type=""></failure>
		</testcase>
	</testsuite>
</testsuites>

haudren-woven added a commit to haudren-woven/test-reporter that referenced this issue Nov 25, 2022
This commit fixes dorny#137. Some JUnit generators emit an empty failure tag,
with only a message property set. In those cases, the parser crashes
when trying to match the failure with a source file. Since this feature
is optional, the simplest fix is to skip the processing when the failure
tag is empty.

Also added a test, and the corresponding input file is generated from a
reporter within our codebase.
haudren-woven added a commit to haudren-woven/test-reporter that referenced this issue Nov 28, 2022
This commit fixes dorny#137. Some JUnit generators emit an empty failure tag,
with only a message property set. In those cases, the parser crashes
when trying to match the failure with a source file. Since this feature
is optional, the simplest fix is to skip the processing when the failure
tag is empty.

Also added a test, and the corresponding input file is generated from a
reporter within our codebase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants