ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Royston McNeill" <roys...@pressroom.com>
Subject RE: JUnit example request
Date Mon, 05 Feb 2001 23:20:02 GMT
Here's an example of a JUnit compilation/test phase build.xml.  I use the
"junit" optional taks include in the optional.jar provide by Jakarta.  The
results from the build produce an XML file that I feed to an HTML file for
other developers.  Enjoy!

........................


<project name = "Proj1:FileSystem" default="dist" basedir=".">

  <!-- set global properties for this build -->
  <property name = "src.dir" value="src" />
  <property name="build.dir" value="build/classes" />
  <property name="dist"  value="dist" />
  <property name="doc.dir" value="api" />
  <property name="test.dir" value="tests" />

  <target name="prepare">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build.dir}" />
    <!-- Create javadoc directory -->
    <mkdir dir="${doc.dir}" />
    <!-- Create junit test directory -->
    <mkdir dir="${test.dir}" />

  </target>

  <target name="JUNIT">
    <available property="junit.properties"
classname="junit.framework.TestCase" />
  </target>

  <target name="compile" depends="JUNIT">
    <mkdir dir="${build.dir}" />
    <javac srcdir="${src.dir}" destdir="${build.dir}"  >

      <!-- include all java files -->
      <include name="**/*.java" />

      <!-- exlude files in the 'javacard' directory -->
      <exclude name="**/javacard/*.java" />
    </javac>

  </target>

  <target name="clean">
    <!-- Delete the ${build.dir} directory -->
    <delete dir="${build.dir}" />
    <delete dir="build/testcases" />
  </target>

  <target name="doc">
    <javadoc sourcepath="${build.dir}"
             destdir="${doc.dir}"
             sourcefiles="*.java" >

    </javadoc>
  </target>

  <target name="compiletests" depends="compile">
    <mkdir dir="build/testcases" />
    <javac srcdir="${test.dir}" destdir="build/testcases" >
       <include name="**/*.java" />
       <!-- include the build.dir so we can run the tests -->
       <classpath>
           <pathelement path="${build.dir}" />
       </classpath>
    </javac>
  </target>

  <target name="runtest">
    <junit printsummary="yes" fork="no" haltonfailure="no">
       <formatter type="xml" />
       <classpath>
           <!-- INCLUDE BUILD DIR PATH FOR TEST RUN -->
           <pathelement location="${test.dir}" />
           <pathelement path="${java.class.path}" />
           <pathelement path="build/testcases" />
           <pathelement path="${build.dir}" />
       </classpath>
       <test name="FileSystemTest" outfile="${test.dir}/TEST" />
    </junit>
  </target>

</project>


-----Original Message-----
From: Spencer A Marks [mailto:smarks@digisolutions.com]
Sent: Monday, February 05, 2001 6:18 PM
To: ant-user@jakarta.apache.org
Subject: JUnit example request


Hi,

I was hoping someone could send or post build.xml snippets that use the
JUnit task def? I'd like to see some real world examples.

Thanks.

Spencer



Mime
View raw message