Skip to content

JUnit xml with nested testsuites aren't merged correctly #227

@superflyxxi

Description

@superflyxxi

When a junit.xml file has a testsuite within a testsuite, the final merged XML has the child testsuite repeated. It appears as though each testsuite element is copied as a child of the root testsuites element. The copy includes all its children. So here, the grandparent "" testsuite is added to the root, then the parent "all" is added, and then each child, "AudioTest" and "BasicTest", are added. Resulting in "AudioTest" and "BasicTest" testsuites appearing 3 times (and their testcases).

We should try to keep the structure the same.

junit-1.xml

<testsuites>
  <testsuite name="" tests="17" assertions="164" errors="0" warnings="0" failures="0" skipped="1" time="93.134026">
    <testsuite name="all" tests="17" assertions="164" errors="0" warnings="0" failures="0" skipped="1" time="93.134026">
      <testsuite name="AudioTest" file="/opt/video-converter/tests/AudioTest.php" tests="1" assertions="8" errors="0" warnings="0" failures="0" skipped="0" time="1.970274">
        <testcase name="testChannelMappingOverrideToLowerValue" class="AudioTest" classname="AudioTest" file="/opt/video-converter/tests/AudioTest.php" line="6" assertions="8" time="1.970274"/>
      </testsuite>
      <testsuite name="BasicTest" file="/opt/video-converter/tests/BasicTest.php" tests="6" assertions="76" errors="0" warnings="0" failures="0" skipped="0" time="1.318233">
        <testcase name="testNoInputSpecifiedWithOnlyOneFile" class="BasicTest" classname="BasicTest" file="/opt/video-converter/tests/BasicTest.php" line="9" assertions="20" time="0.428660"/>
      </testsuite>
    </testsuite>
  </testsuite>
</testsuites>

Final junit.xml

<testsuites failures="0" errors="0" tests="81" skipped="3">
  <testsuite name="" tests="17" assertions="164" errors="0" warnings="0" failures="0" skipped="1" time="93.134026">
    <testsuite name="all" tests="17" assertions="164" errors="0" warnings="0" failures="0" skipped="1" time="93.134026">
      <testsuite name="AudioTest" file="tests/AudioTest.php" tests="1" assertions="8" errors="0" warnings="0" failures="0" skipped="0" time="1.970274">
        <testcase name="testChannelMappingOverrideToLowerValue" class="AudioTest" classname="AudioTest" file="tests/AudioTest.php" line="6" assertions="8" time="1.970274"/>
      </testsuite>
      <testsuite name="BasicTest" file="tests/BasicTest.php" tests="6" assertions="76" errors="0" warnings="0" failures="0" skipped="0" time="1.318233">
        <testcase name="testNoInputSpecifiedWithOnlyOneFile" class="BasicTest" classname="BasicTest" file="tests/BasicTest.php" line="9" assertions="20" time="0.428660"/>
      </testsuite>
    </testsuite>
  </testsuite>
  <testsuite name="all" tests="17" assertions="164" errors="0" warnings="0" failures="0" skipped="1" time="93.134026">
    <testsuite name="AudioTest" file="tests/AudioTest.php" tests="1" assertions="8" errors="0" warnings="0" failures="0" skipped="0" time="1.970274">
      <testcase name="testChannelMappingOverrideToLowerValue" class="AudioTest" classname="AudioTest" file="tests/AudioTest.php" line="6" assertions="8" time="1.970274"/>
    </testsuite>
    <testsuite name="BasicTest" file="tests/BasicTest.php" tests="6" assertions="76" errors="0" warnings="0" failures="0" skipped="0" time="1.318233">
      <testcase name="testNoInputSpecifiedWithOnlyOneFile" class="BasicTest" classname="BasicTest" file="tests/BasicTest.php" line="9" assertions="20" time="0.428660"/>
    </testsuite>
  </testsuite>
  <testsuite name="AudioTest" file="tests/AudioTest.php" tests="1" assertions="8" errors="0" warnings="0" failures="0" skipped="0" time="1.970274">
    <testcase name="testChannelMappingOverrideToLowerValue" class="AudioTest" classname="AudioTest" file="tests/AudioTest.php" line="6" assertions="8" time="1.970274"/>
  </testsuite>
  <testsuite name="BasicTest" file="tests/BasicTest.php" tests="6" assertions="76" errors="0" warnings="0" failures="0" skipped="0" time="1.318233">
    <testcase name="testNoInputSpecifiedWithOnlyOneFile" class="BasicTest" classname="BasicTest" file="tests/BasicTest.php" line="9" assertions="20" time="0.428660"/>
  </testsuite>
</testsuite>

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