Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

phpunit producing junit results that junitPublish warns on

I've checked for an answer but haven't found a solution to tweek the phpunit junit results for publishing back to RTC. Or maybe there's a parameter for junitLogPublish.

I have an ant build script calling phpunit with a configuration file to the tests.  I call junitLogPublish on the results and see this warning.

     [exec] Time: 256 ms, Memory: 4.50Mb
     [exec] 
     [exec] OK (14 tests, 20 assertions)
[junitLogPublisher] Non-fatal errors occurred while publishing "/local/scdevlkg/jenkins/workspace/SFA2.0-test/scrm-dataintegration.comp/di.batch/lwp/junit_results/tests-bvt-csvdelta-junit.xml":
[junitLogPublisher] 	Found unexpected element "testsuite" inside element "testsuite".
[junitLogPublisher] 	Found unexpected element "testsuite" inside element "testsuite".
     [exec] PHPUnit 3.7.28 by Sebastian Bergmann.

Here's the junit result.
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="SCLoggerTests" tests="3" assertions="3" failures="0" errors="0" time="0.010105">
    <testsuite name="CSLoggerTest" file="/local/scdevlkg/jenkins/workspace/SFA2.0-test/scrm-dataintegration.comp/di.batch/lwp/di.batch.test/SCUnitTests/SCLoggerTests/SCLoggerTest.php" tests="3" assertions="3" failures="0" errors="0" time="0.010105">
      <testcase name="testPrint" class="CSLoggerTest" file="/local/scdevlkg/jenkins/workspace/SFA2.0-test/scrm-dataintegration.comp/di.batch/lwp/di.batch.test/SCUnitTests/SCLoggerTests/SCLoggerTest.php" line="26" assertions="1" time="0.005086"/>
      <testcase name="testSetLevel" class="CSLoggerTest" file="/local/scdevlkg/jenkins/workspace/SFA2.0-test/scrm-dataintegration.comp/di.batch/lwp/di.batch.test/SCUnitTests/SCLoggerTests/SCLoggerTest.php" line="32" assertions="1" time="0.001173"/>
      <testcase name="testPrintCommonLogger" class="CSLoggerTest" file="/local/scdevlkg/jenkins/workspace/SFA2.0-test/scrm-dataintegration.comp/di.batch/lwp/di.batch.test/SCUnitTests/SCLoggerTests/SCLoggerTest.php" line="39" assertions="1" time="0.003846"/>
    </testsuite>
  </testsuite>
</testsuites>

Thanks.

0 votes



2 answers

Permanent link
As far as I know, the build result publishing for the JUnit results depends on the XML structure and data. If your data does not match the JUNIT schema, you can run into problems. You can use XML tooling to modify the data you have to match JUNIT and upload that data.

0 votes


Permanent link
<?xml version="1.0" encoding="UTF-8"?>
Thanks. I was able to eliminate the junit warnings about the outer testsuite and test-case missing classname attribute with this xsl.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/testsuites">
    <testsuites>
        <xsl:apply-templates select="//testsuite[@file]"/>
    </testsuites>
</xsl:template>

<xsl:template match="*">
    <xsl:element name="{name()}">
        <xsl:apply-templates select="@*"/>
        <xsl:apply-templates/>
    </xsl:element>
</xsl:template>

<xsl:template match="@class">
    <xsl:attribute name="classname"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>

<xsl:template match="@*">
    <xsl:copy/>
</xsl:template>

</xsl:stylesheet>

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 8
× 2

Question asked: Mar 13 '14, 10:28 a.m.

Question was seen: 3,952 times

Last updated: Mar 19 '14, 3:27 p.m.

Confirmation Cancel Confirm