Krishna Rajendra Alapati

IT Professional having 4+ years of experience on Java and JEE technologies. Good experience in working with Servlets, JSP, EJB2, XML, XSLT and JEE Design patterns. Good experience in working with open source frameworks like Struts, Spring, Hibernate, ANT, JUnit and JMock.

My Photo
Name:
Location: London, Ilford, United Kingdom

Wednesday, January 25, 2006

Running the Testcases using ANT script

ANT provides the task to run the JUnit test cases

For using this task we need to have junit.jar file in classpath instead we can copy that jar file into our ANT_HOME\lib folder
below i have given a sample example to run the junit test cases

<junit printsummary="no" haltonfailure="no">
<jvmarg value="-classic"/>
<classpath>
<pathelement path="${app.classpath}" />
<pathelement path="${app.build-test}" />
<pathelement path="${app.build-classes}" />
</classpath>
<formatter type="xml" usefile="true" />
<batchtest>
<fileset dir="${app.build-test}">
<include name="**/test/beans/XML*Test.class" />
<!-- sandbox -->
</fileset>
</batchtest>
</junit>

to understan more about this junit task u can go throug the below link

More help on Junit Ant Task

we can use the junitreport task to generate the report for the junit testcases after running the junit task we can get the xml files
if we use this task after junit we can have a HTML junit task reports which looks like java doc with all the information i.e

tests runned
failures
errors
etc......

Below is a sample code for the junitreport task

<junitreport todir=".">
<fileset dir=".">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${app.build-test-report}/html"/>
</junitreport>

to understan more about this junitreport task u can go throug the below link
More help on junitreport Ant Task

to run the junitreport we need to put the xalan.jar in the classpath otherwise we can copy this in to ANT_HOME\lib
Note:if You are using xalan2.7.0 then we need to copy serializer.jar and xsltc.jar along with the xalan.jar

0 Comments:

Post a Comment

<< Home