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

Problem with JUnit Publishing

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

0 votes



8 answers

Permanent link
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

0 votes


Permanent link
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

0 votes


Permanent link
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

0 votes


Permanent link
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.

0 votes


Permanent link
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?

0 votes


Permanent link
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.

0 votes


Permanent link
For an example of using XSLT to process test results, see:
http://jazz.net/forums/viewtopic.php?t=5906

0 votes


Permanent link
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.

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

Question asked: Feb 12 '10, 5:30 p.m.

Question was seen: 9,563 times

Last updated: Feb 12 '10, 5:30 p.m.

Confirmation Cancel Confirm