Blog post after a long time but this one deserves it because this can save someone a day or few minutes/hours of their time for sure.
Issue: When you run JUnit report generation using Ant target
Where: Happens only on Windows machine (at least I have seen it). Works fine on linux/mac os x.
Why: When XSLT engine runs thru all the properties supplied to it while doing the actual test case to report translation, it runs into java.class.path variable specified and if your class path has too many path elements , it goes into infinite death loop.
How to fix: A Quick hack or fix (whatever you want to call it as); is to tell XSLT engine ignore the java.class.path while evaluating properties. To do that you will have to explicitly specify where to pick up the stylesheet from. Luckily junitreport lets us specify the external xsl folder location using styledir attribute in
<report ...
tag. So this is what you need to do.
- get a copy of junit-noframes.xsl (if you are using with frames get a copy of that) from the internet. or you should be able to get this from the latest version of Apache Ant and it should be located in /etc folder. Now copy this xsl fi
- Now change
<xsl:template match="properties">
section from
<xsl:for-each select="property">
to
<xsl:for-each select="property[not(@name = 'java.class.path')]">
and save this file in some location e.g c:/junit/xsl
- In your ant target explicitly specify the junit-noframes.xsdl location by adding styledir . It should look something like this
<report format="noframes" todir="${junit.test.reports.dir}" styledir="c:/junit/xsl" />
That should fix the issue.
Point # 2 above tells the xsl engine to ignore classpath variable.