Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Howto merge two CppUnit xml results files

2008-09-26
2013-04-22
  • Niket Chhajed
    Niket Chhajed
    2008-09-26

    Hi

    I am looking for a way to merge the contents of two xml results file that are generated as a result of CppUnit test execution.

    I have used CPPUNIT_NS::XmlOutputter to generate these 2 results files. Is there a way of directly merging these two files using CppUnit framework classes without actually writing the code to parse the two files from scratch? I found that in CppUnit fwk., there is a way of writing data from XmlOutputter to an xml file, but did not find a way of reading from an xml file to a CppUnit compatible class like the XmlOutputter.

    A typical CppUnit xml results file looks like this:

    <?xml version="1.0" encoding='utf-8' standalone='yes' ?>
    <TestRun>
      <FailedTests>
        <FailedTest id="1">
          <Name>InviteConsTest::inviteConsProcessTxAllValid</Name>
          <FailureType>Assertion</FailureType>
          <Location>
            <File>inviteConsTest.cpp</File>
            <Line>111</Line>
          </Location>
          <Message>equality assertion failed
    - Expected: 3
    - Actual  : 2
    </Message>
        </FailedTest>
        <FailedTest id="6">
          <Name>InviteConsTest::inviteConsProcessTxContainsTargetGuid</Name>
          <FailureType>Assertion</FailureType>
          <Location>
            <File>inviteConsTest.cpp</File>
            <Line>301</Line>
          </Location>
          <Message>equality assertion failed
    - Expected: 3
    - Actual  : 2
    </Message>
        </FailedTest>
      </FailedTests>
      <SuccessfulTests>
        <Test id="2">
          <Name>InviteConsTest::inviteConsProcessTxAllInvalid</Name>
        </Test>
        <Test id="3">
          <Name>InviteConsTest::inviteConsProcessTxInvalidGuid</Name>
        </Test>
        <Test id="4">
          <Name>InviteConsTest::inviteConsProcessTxInvalidStatus</Name>
        </Test>
        <Test id="5">
          <Name>InviteConsTest::inviteConsProcessTxNotExistsStatus</Name>
        </Test>
        <Test id="7">
          <Name>InviteConsTest::inviteConsProcessTxNotContainRequiredFields</Name>
        </Test>
      </SuccessfulTests>
      <Statistics>
        <Tests>7</Tests>
        <FailuresTotal>2</FailuresTotal>
        <Errors>0</Errors>
        <Failures>2</Failures>
      </Statistics>
    </TestRun>

    Thanks in advance
    Niket