File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Empty Junit reports from ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Empty Junit reports from ant" Watch "Empty Junit reports from ant" New topic
Author

Empty Junit reports from ant

ParagM Pmahajan
Greenhorn

Joined: Nov 16, 2011
Posts: 10
Hi ,

I am trying to use ant to run junit tests and generate reports.
I am able to successfully run the tests but the report files are empty.

Can somebody please help me out ?

This is my build.xml :

<project name="JunitTest" default="test" basedir=".">

<property name="testdir" location="." />
<property name="srcdir" location="." />
<property name="full-compile" value="true" />

<property name="test.reports" value="./reports" />

<path id="classpath.base"/>

<path id="classpath.test">
<pathelement location="${testdir}" />
<pathelement location="${srcdir}" />
<path refid="classpath.base" />
</path>

<target name="clean" >
<delete verbose="${full-compile}">
<fileset dir="${testdir}" includes="**/*.class" />
</delete>
</target>

<target name="compile" depends="clean">
<javac srcdir="${srcdir}" destdir="${testdir}" verbose="${full-compile}" >
<classpath refid="classpath.test"/>
</javac>
</target>

<target name="test" depends="compile">
<junit>
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false" />
<test name="com.tests.nav1" />
</junit>

<junitreport todir="${test.reports}">
<fileset dir="${test.reports}">
<include name="TEST-*.xml" />
</fileset>
<report todir="${test.reports}" />
</junitreport>
</target>

</project>


and this is the output on the console :

[junit] Using CLASSPATH C:\eclipse\eclipse-java-helios-SR1-win32\eclipse\JunitWS\SeleniumTraining\src;C:\jars\junit.jar;C:\ant\lib\ant-launcher.jar;C:\ant\lib\ant.jar;C:\ant\lib\ant-junit.jar;C:\ant\lib\ant-junit4.jar
[junit] Testsuite: com.tests.nav1
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 48.187 sec
[junit]
[junit] ------------- Standard Output ---------------
[junit] testnav2
[junit] ------------- ---------------- ---------------
[junitreport] Using class org.apache.tools.ant.taskdefs.optional.TraXLiaison
[junitreport] Processing C:\eclipse\eclipse-java-helios-SR1-win32\eclipse\JunitWS\SeleniumTraining\src\reports\TESTS-TestSuites.xml to C:\Users\pmahajan\AppData\Local\Temp\null236099757
[junitreport] Loading stylesheet jar:file:/C:/ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] Transform time: 330ms
[junitreport] Deleting: C:\Users\pmahajan\AppData\Local\Temp\null236099757

BUILD SUCCESSFUL
Total time: 49 seconds
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Hello, in this posts I show how to create a JUnit coverage report with Cobertura and Emma: Covering your tests with Cobertura, JUnit, HSQLDB, JPA, TDD Coverage of tests with JUnit Ant and Emma, just in case you get interested.

I noticed that when we want to create JUnit report only, usually we need to compile our code with the debug mode on, like this:


If you use the eclipse IDE you can use the export option and select the ant option. It will create a build.xml file with a JUnit report with a full setup on it.


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Empty Junit reports from ant
 
Similar Threads
java.lang.classnotfoundexception in junit report
can't generate JUnit report
Create XML from Junit Testing
ANT issues - Unable to create JUnit Reports- Please help
Ant Build file HELP!!-URGENT