Problem with JUnit Publishing
![](http://jazz.net/_images/myphoto/7ef68afb1147f3ba2a13ee9112375997.jpg)
Hi! We're using RTC to automate WebSphere Integration Developer (WID) 6.2.0.2 component test. WID is an IBM integrated development environment. Its component test allows you to define test suites and test cases for automated testing of the integration components.
Our test runs fine but there's an error parsing the XML file when publishing the JUnit results.
The output from the WID component test looks like the following:
The warning message is for the "resource" tag. I'm not sure if it's for the high-level one or the one in the variations.
Is this a valid JUnit XML file? Should the RTC publish be able to handle this? We have an old version of RTC (1.0.1.1) so it's possible this is fixed in a more recent version.
FWIW, I've tried searching for a schema or DTD that defines the JUnit test results but I couldn't find anything.
Thanks in advance for any help.
Benny L. Higdon
Our test runs fine but there's an error parsing the XML file when publishing the JUnit results.
The output from the WID component test looks like the following:
<xml>
<resource>
<testsuite>
<testcase>
<variation>
<severity>pass</severity>
<description>Default pass</description>
<resource>HelloWorldComponentTest</resource>
</variation>
</testcase>
</testsuite>
<testsuite>
<testcase>
<variation>
<severity>pass</severity>
<description>Default pass</description>
<resource>HelloWorldComponentTest</resource>
</variation>
</testcase>
</testsuite>
</resource>
The warning message is for the "resource" tag. I'm not sure if it's for the high-level one or the one in the variations.
Is this a valid JUnit XML file? Should the RTC publish be able to handle this? We have an old version of RTC (1.0.1.1) so it's possible this is fixed in a more recent version.
FWIW, I've tried searching for a schema or DTD that defines the JUnit test results but I couldn't find anything.
Thanks in advance for any help.
Benny L. Higdon
8 answers
![](http://jazz.net/_images/myphoto/7ef68afb1147f3ba2a13ee9112375997.jpg)
Hi! We're using RTC to automate WebSphere Integration Developer (WID) 6.2.0.2 component test. WID is an IBM integrated development environment. Its component test allows you to define test suites and test cases for automated testing of the integration components.
Our test runs fine but there's an error parsing the XML file when publishing the JUnit results.
The output from the WID component test looks like the following:
<xml>
<resource>
<testsuite>
<testcase>
<variation>
<severity>pass</severity>
<description>Default pass</description>
<resource>HelloWorldComponentTest</resource>
</variation>
</testcase>
</testsuite>
<testsuite>
<testcase>
<variation>
<severity>pass</severity>
<description>Default pass</description>
<resource>HelloWorldComponentTest</resource>
</variation>
</testcase>
</testsuite>
</resource>
The warning message is for the "resource" tag. I'm not sure if it's for the high-level one or the one in the variations.
Is this a valid JUnit XML file? Should the RTC publish be able to handle this? We have an old version of RTC (1.0.1.1) so it's possible this is fixed in a more recent version.
FWIW, I've tried searching for a schema or DTD that defines the JUnit test results but I couldn't find anything.
Thanks in advance for any help.
Benny L. Higdon
I've verified that IBM is using an internal format. Also, the latest WID release (V7) also uses this proprietary format :-(
By trial and error, I was able to create an XSLT to generate a JUnit compatible format. So, I'm good to go.
Benny L. Higdon
![](http://jazz.net/_images/myphoto/7ef68afb1147f3ba2a13ee9112375997.jpg)
Hi Benny,
I see this was never responded to. Sorry about that. Is this still an issue for you?
Regarding the non-standard format, are you saying that WID outputs a non-standard format, or that RTC does not honour the standard format, or both?
Even if it's non-standard, we could perhaps enhance the existing JUnit publisher to understand this format, if it makes sense.
Thanks,
Nick
I see this was never responded to. Sorry about that. Is this still an issue for you?
Regarding the non-standard format, are you saying that WID outputs a non-standard format, or that RTC does not honour the standard format, or both?
Even if it's non-standard, we could perhaps enhance the existing JUnit publisher to understand this format, if it makes sense.
Thanks,
Nick
![](http://jazz.net/_images/myphoto/7ef68afb1147f3ba2a13ee9112375997.jpg)
Nick,
This is no longer an issue since I was able to create a stylesheet to transform the WID format into one that RTC would publish.
I believe that it is WID that is using a non-standard format. However, I'm not a JUnit guru so I can't say for sure. I included an example of the WID output in my append so perhaps someone more knowledgeable about JUnit can comment.
As for existing the existing JUnit publisher, I'm not sure that it should be tied to an IBM proprietary format.
Benny
This is no longer an issue since I was able to create a stylesheet to transform the WID format into one that RTC would publish.
I believe that it is WID that is using a non-standard format. However, I'm not a JUnit guru so I can't say for sure. I included an example of the WID output in my append so perhaps someone more knowledgeable about JUnit can comment.
As for existing the existing JUnit publisher, I'm not sure that it should be tied to an IBM proprietary format.
Benny
![](http://jazz.net/_images/myphoto/7ef68afb1147f3ba2a13ee9112375997.jpg)
Benny actually posted an XSLT to do exactly as suggested above:
http://ibmforums.ibm.com/forums/message.jspa?messageID=1762894
Not sure if that's behind the firewall, so I'm posting it here too:
Benny, if you're not OK with me posting it here, just let me know and I'll delete this post.
http://ibmforums.ibm.com/forums/message.jspa?messageID=1762894
Not sure if that's behind the firewall, so I'm posting it here too:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="resource">
<xsl:element name="testsuites">
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="testcase/variation"/>
<xsl:attribute-set name="testsuiteAttrs">
<xsl:attribute name="errors">
<xsl:value-of select="@totalTests - count(./testcase[@result = 'pass'])" />
</xsl:attribute>
<xsl:attribute name="failures">0</xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="tests"><xsl:value-of select="@totalTests"/></xsl:attribute>
<xsl:attribute name="time">
<xsl:value-of select="(@end - @start) div 1000"/></xsl:attribute>
</xsl:attribute-set>
<xsl:template match="testsuite">
<xsl:element name="testsuite" use-attribute-sets="testsuiteAttrs">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:attribute-set name="testcaseAttrs">
<xsl:attribute name="classname"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="time">
<xsl:value-of select="(@end - @start) div 1000"/>
</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="testcase">
<xsl:element name="testcase" use-attribute-sets="testcaseAttrs">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Benny, if you're not OK with me posting it here, just let me know and I'll delete this post.