testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.98k stars 1.02k forks source link

testng-results.xml order not preserved in junitreports/TEST-*.xml #421

Open mauriziokg opened 11 years ago

mauriziokg commented 11 years ago

Today I migrated one of our projects from junit4 to testNG (version testng-6.8.5). Since I prefer the keep the layout of junitreport I use the junitreport ant task to convert the junitreports/TEST-.xml file generated by testNG into a standard junit report. I noticed that the order in the resulting junit report was wrong, even though I had observed during execution that the tests had been run in the right order. When investigating upon this, I found that test-results.xml listed the tests in the real execution order (which in my case is also the alphabetical order btw), but the corresponding junitreports/TEST-.xml file had the wrong order (random as it seems). I checked lots of documentation, problem reports, etc. but could not find this problem so I create a new ticket (sorry if I overlooked something).

mauriziokg commented 11 years ago

I close this ticket because I found a solution to my problem: when calling the junitreport ant task I now use a modified style sheet junit-frames.xsl (by setting the styledir attribute of the <report> element). The modification to the stylesheet (in 6 locations) is the addition of <xsl:sort select="@name"/>, e.g.

<xsl:apply-templates select="./testcase" mode="print.test"/>

becomes

<xsl:apply-templates select="./testcase" mode="print.test">
    <xsl:sort select="&#64;name"/>
 </xsl:apply-templates>

It would however have been more easy if the order in junitreports/TEST-*.xml were preserved...