It's all about the answers!

Ask a question

Problem with JUnit Publishing


Benny Higdon (1611) | asked Feb 12 '10, 5:30 p.m.
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

8 answers



permanent link
Benny Higdon (1611) | answered Feb 19 '10, 10:47 p.m.
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

permanent link
Nick Edgar (6.5k711) | answered Apr 18 '10, 2:40 p.m.
JAZZ DEVELOPER
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

permanent link
Benny Higdon (1611) | answered Apr 19 '10, 11:13 a.m.
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

permanent link
Nick Edgar (6.5k711) | answered Apr 19 '10, 11:44 a.m.
JAZZ DEVELOPER
Looking at the source for Ant's XMLJUnitResultFormatter, it only uses <testsuite> as the root element(s) and knows nothing about <resource> elements, so I agree the WID format is non-standard. And I agree that it would be odd for RTC to support this. Thanks for clarifying.

permanent link
Chris Novak (2621) | answered Nov 23 '10, 10:55 p.m.
Is anyone aware of an Ant task than can be used to parse a WID component test output XML file and publish the results to the RTC server as a part of the build report?

permanent link
Nick Edgar (6.5k711) | answered Nov 24 '10, 10:24 a.m.
JAZZ DEVELOPER
Since the format is so close (yet so far) from the JUnit XML file format, it should be pretty straightforward to come up with a sed or awk shell script, or XSLT transform, that removes the extra <resource> tags.

You could then use the existing junitLogPublisher task.

permanent link
Nick Edgar (6.5k711) | answered Nov 24 '10, 1:37 p.m.
JAZZ DEVELOPER
For an example of using XSLT to process test results, see:
http://jazz.net/forums/viewtopic.php?t=5906

permanent link
Nick Edgar (6.5k711) | answered Nov 25 '10, 12:04 p.m.
JAZZ DEVELOPER
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:

<?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.

Your answer


Register or 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.