Sponsered Links
Categories
Sponsered Links

Ant Junit Test Example

 

This is a simple Ant Junit Test Example.

build.xml

<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.2/lib/junit-3.8.1.jar" />
    <pathelement location="/apache-ant-1.7.2/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="JUnitTestApplication" />
    </junit>
  </target>

</project>

 

JUnitTestApplication.java

import junit.framework.*;

public class JUnitTestApplication extends TestCase{
    public void testCase1(){
    assertTrue( "JUnit Test Result:"true );
  }
}

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved