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

Error: Cannot read property 'split' of undefined - when a sub test case fails #256

Open
acpbm opened this issue Aug 4, 2023 · 3 comments

Comments

@acpbm
Copy link

acpbm commented Aug 4, 2023

When creating a test report from the XML file, I get an error that says:

  • Cannot read property 'split' of undefined

This error only occurs when a subtest fails. Looking closely at the XML file with the test results, I see that the failure element within the testscase element is empty (since this is the parent test case that holds the subtests).

See example here

<?XML version="1.0" encoding="UTF-8"?>
<testsuites>
    <testsuite test="3" failures="2" time"81.409" name="Test">
        <properties>
            <property name="go.version" value=:go1.18.10"></property>
        </properties>
        <testcase classname="test" name="testmain" time="81.000">
            <failure message=Failed" type="">
               **This is empty since this top-level test case is just a parent test function that holds the test cases**
            <failure>
        </testcase>
        <testcase classname="test" name="subtest1" time="44.590">
            <failure message=Failed" type="">
               **All the logs from the failed subtest; many, many logs here.**
            <failure>
        </testcase>
        <testcase classname="test" name="subtest1" time="36.410"></testcase>
    </testsuite>
</testsuites>

It appears to be related to how the XML file is parsed, as it expects the failure element not to be empty.

See code here:

https://github.com/dorny/test-reporter/blob/main/src/parsers/java-junit/java-junit-parser.ts#L116

Do you have any workarounds for this behavior?

@acpbm
Copy link
Author

acpbm commented Aug 16, 2023

Will the PR created by cazou be merged any time soon?

@BartDecker
Copy link

Same problem here. Bump

@radeusgd
Copy link

I've also been encountering this problem.
My workaround has been to amend the code generating the XML files to ensure that the <failure> tag always has some inner text content. After that, the workflow works again and correctly displays the test reports.

Still, ideally, the code should check this edge case and work even if the <failure> tag doesn't have inner contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants