aspose file tools*
The moose likes Testing and the fly likes Question about JUnitReport task Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Question about JUnitReport task" Watch "Question about JUnitReport task" New topic
Author

Question about JUnitReport task

Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
I am trying to create a report after a junit test is completed.

When I tried to use the JUnitReport task, it is not creating the desired xml that can be use to show the results in a frame format.

I know we need xalan to get JUnit task going. Do I need any thing else so that a meaningful(frames) report is generated??


Kishore
SCJP, blog
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Could you post the <target>'s you're using to 1) run the tests and 2) generate the report?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
it looks like this:

<project name="junittest" default="test" basedir=".">
<target name="test">
<junit printsummary="true" haltonfailure="true">
<formatter type="brief" usefile="true" />
<formatter type="xml" />
<test name="cingcom.estorepost.test.TestXstreamTest" />
</junit>
<junitreport todir="./reports">
<fileset dir="./reports">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="./reports/html"/>
</junitreport>
</target>
</project>

Also in the ant javadocs it says something like:
"If you want to use Xalan 1.2.2, the noframes report is still supposed to work. If you want the frames support, copy the file junit-frames-xalan1.xsl from the Ant distribution's etc directory to a new directory, change its name to junit-frames.xsl and use the task's styledir attribute to point to it. You will also need a compatible (older) version of Xerces. as well as BSF(bsf.jar). Again, using Xalan 2 is simpler and supported."

The javadoc prescribes to go the route of noframes, which kind of defeates the purpose of creating a decent test report

BTW i am using jdk1.3.1, if that makes any sense.
[ August 23, 2004: Message edited by: Kishore Dandu ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
At least you have a problem where the <junit> task generates test results (TEST-*.xml) into the current directory but you're telling <junitreport> to look for them in a directory named reports.
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
thanks for the correction.

It works nice and generates a no frames html(when report format selection is noframes).

But if I have report format changed to frames, the output is not very user friendly. Any ideas??

I get the following exception during the frames report generation.

[junitreport] jar:file:/C:/ant/apache-ant-1.6.2/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl; Line 107; Column 81; javax.xml.transform.TransformerException: java.lang.ClassNotFoundException: redirect
[ August 23, 2004: Message edited by: Kishore Dandu ]
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
I got everything figureout by adding styledir attribute to the report task.
Siva Jagadeesan
Ranch Hand

Joined: Oct 31, 2000
Posts: 160
Check this link

http://java2simple.blog-city.com/read/831662.htm


Rgds<p>--Siva Jagadeesan<br /><a href="http://java2simple.blog-city.com" target="_blank" rel="nofollow">http://java2simple.blog-city.com</a><br />Sun Certified Java2 Programmer<br />Sun Certified Web Component Developer<br />BEA Certified Weblogic Server 7 Enterprise Developer
h Huang
Greenhorn

Joined: Mar 09, 2005
Posts: 2
check this:
Ant 1.6.2 <junitreport> doesn't work on Java 1.4.1
http://twasink.net/blog/archives/2004/07/ant_162_junitre.html

In a summary, you should at least use JDK 1.4.2

or:
"When the Xalan.jar was copied to j2sdk1.4.1_01\jre\lib\endorsed and the ant script was run the problem went away."
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question about JUnitReport task
 
Similar Threads
Report Based on JUnit Test Case
Get report from running external tests
Error! Unrecognized XSLTC extension 'org.apache.xalan.lib.Redirect:write'
how to customize junit reports?
How to determine what the error is when running a JUnit test via Ant