More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Ant and JUnit 
 

This example illustrates how to implement junit test case with ant script. This is a basic tutorial to implement JUnit framework with ANT technology.

 

Ant and JUnit

                         

This example illustrates how to implement junit test case with ant script. This is a basic tutorial to implement JUnit framework with ANT technology. Before creating any test case you will need Java compiler, Ant and JUnit. You will also need junit.jar in your Ant's library folder.

Download the junit.jar file from the given link http://junit.org/ and paste this jar file in ANT_HOME/lib folder. Then create a build.xml file as shown below.

 

 

 


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

  <path id="classpath.base"/>
  
  <path id="classpath.test">
    <pathelement location="/apache-ant-1.7.1/lib/junit-3.8.1.jar" />
    <pathelement location="/apache-ant-1.7.1/lib/junit-3.8.jar" />
    <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="JUnitTestExample" />
    </junit>
  </target>

</project>


Create a JUnitTestExample.java file in the src directory as given below.

import junit.framework.*;

public class JUnitTestExample extends TestCase{
    public void testCase1(){
    assertTrue( "TestExample"true );
  }
}


If you run the source code with ant command, then the following output will be displayed.


If you compile with ant -verbose test command, then the following output will be displayed.


Download Source Code

                         

» View all related tutorials
Related Tags: sql c database xml file url data ui build property user sed password word driver vi name using this element

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.