Skip to content

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

@acpbm

Description

@acpbm

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions