More test revamping.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2011 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2006-12-21 21:58:33 +00:00
parent e04f24077f
commit e5ae86c047
10 changed files with 23 additions and 129 deletions
+22 -5
View File
@@ -46,7 +46,6 @@
<delete dir="${deploy.dir}/classes"/> <delete dir="${deploy.dir}/classes"/>
<delete dir="${deploy.dir}/docs"/> <delete dir="${deploy.dir}/docs"/>
<delete failonerror="false"><fileset dir="${deploy.dir}" includes="*.jar"/></delete> <delete failonerror="false"><fileset dir="${deploy.dir}" includes="*.jar"/></delete>
<ant dir="tests" target="clean"/>
</target> </target>
<!-- wipes the entire build directory clean --> <!-- wipes the entire build directory clean -->
@@ -113,15 +112,33 @@
<!-- a target for rebuilding everything --> <!-- a target for rebuilding everything -->
<target name="all" depends="clean,prepare,compile,javadoc,dist"/> <target name="all" depends="clean,prepare,compile,javadoc,dist"/>
<!-- builds the various tests --> <!-- runs our unit tests -->
<target name="tests"> <target name="tests" depends="prepare,compile" description="Runs unit tests.">
<ant dir="tests" target="test"/> <taskdef name="unit" classpathref="classpath"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
<unit printsummary="off" haltonfailure="yes" fork="${junit.fork}">
<classpath>
<pathelement location="${deploy.dir}/classes"/>
<pathelement location="${basedir}"/> <!-- for rsrc/ -->
<fileset dir="${deploy.dir}/lib" includes="*.jar"/>
<fileset dir="lib/test" includes="*.jar"/>
</classpath>
<sysproperty key="test_dir" value="${basedir}"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${src.dir}">
<include name="**/tests/**/*Test.java"/>
</fileset>
</batchtest>
</unit>
</target> </target>
<!-- builds our distribution files (war and jar) --> <!-- builds our distribution files (war and jar) -->
<target name="dist" depends="prepare,compile,tests"> <target name="dist" depends="prepare,compile,tests">
<jar destfile="${deploy.dir}/${app.name}.jar" <jar destfile="${deploy.dir}/${app.name}.jar"
basedir="${deploy.dir}/classes"/> basedir="${deploy.dir}/classes">
<exclude name="**/tests/**" unless="build.io"/>
</jar>
</target> </target>
<!-- converts our 1.5 code to a 1.4 compatible format --> <!-- converts our 1.5 code to a 1.4 compatible format -->
@@ -76,7 +76,7 @@ public class ConfigUtilTest extends TestCase
public void runTest () public void runTest ()
{ {
try { try {
String path = "/rsrc/util/test.properties"; String path = "rsrc/util/test.properties";
Properties props = ConfigUtil.loadInheritedProperties(path); Properties props = ConfigUtil.loadInheritedProperties(path);
assertTrue("props valid", props.toString().equals(DUMP)); assertTrue("props valid", props.toString().equals(DUMP));
-42
View File
@@ -1,42 +0,0 @@
samskivert tests
----------------
This is where all test code for the samskivert library exists. Where
possible unit tests should be created for all services provided by the
library. Tests are implemented using JUnit <http://junit.org> where
applicable and automatically invoked from ant.
Running the tests
-----------------
First build the main library (by invoking ant in the top-level project
directory) and then the tests can be built and invoked via ant:
% ant test
which will build and then invoke the test code.
Adding new tests
----------------
Unit tests are implemented using JUnit which means that they should extend
junit.framework.TestCase and follow the guidelines outlined here
<http://junit.sourceforge.net/> for creating test cases.
Test classfiles should be named <foo>Test.java where <foo> is the
associated class in the samskivert library for which a test is being
implemented. For example, a test for the
com.samskivert.servlet.SiteResourceLoader class would be named
com.samskivert.servlet.SiteResourceLoaderTest.
If multiple test drivers for a single class are desired, they can deviate
from the prescribed naming scheme but must still end with Test.java so
that ant will automatically locate and invoke them as part of the build
process.
Test implementors will want to look at existing tests as a starting point
and at the test support classes in the com.samskivert.test package (which
is part of the main samskivert library source tree, not the test source
tree).
$Id: README,v 1.1 2001/11/05 09:13:25 mdb Exp $
-81
View File
@@ -1,81 +0,0 @@
<!-- build configuration -->
<project name="samskivert tests" default="test" basedir=".">
<!-- we need to do this to avoid conflicts with the XML jar files loaded -->
<!-- to run ant versus the XML jar files we load for our tests -->
<property name="junit.fork" value="true"/>
<!-- things you probably don't want to change -->
<property name="src.dir" value="src/java"/>
<property name="deploy.dir" value="dist"/>
<!-- declare our classpath -->
<path id="classpath">
<pathelement location="../${deploy.dir}/classes"/>
<pathelement location="${deploy.dir}/classes"/>
<fileset dir="../${deploy.dir}/lib" includes="*.jar"/>
<fileset dir="${deploy.dir}/lib" includes="*.jar"/>
</path>
<!-- import some targets to check dependency availability -->
<import file="../depends-incl.xml"/>
<!-- prepares the application directories -->
<target name="prepare">
<mkdir dir="${deploy.dir}"/>
<mkdir dir="${deploy.dir}/lib"/>
<mkdir dir="${deploy.dir}/classes"/>
<copy todir="${deploy.dir}/classes">
<fileset dir="${src.dir}" includes="**/*.properties"/>
</copy>
<mkdir dir="${deploy.dir}/classes/rsrc"/>
<copy todir="${deploy.dir}/classes/rsrc">
<fileset dir="rsrc" includes="**/*"/>
</copy>
<copy todir="${deploy.dir}/lib">
<fileset dir="lib" includes="**/*.jar"/>
</copy>
</target>
<!-- cleans out the installed application -->
<target name="clean">
<delete dir="${deploy.dir}"/>
</target>
<!-- build the java class files -->
<target name="compile" depends="prepare,compute-builds">
<javac srcdir="${src.dir}" destdir="${deploy.dir}/classes"
debug="on" optimize="off" deprecation="off">
<classpath refid="classpath"/>
<exclude name="com/samskivert/io/**" unless="build.io"/>
<exclude name="com/samskivert/jdbc/**" unless="build.jdbc"/>
<exclude name="com/samskivert/net/**" unless="build.net"/>
<exclude name="com/samskivert/servlet/**" unless="build.servlet"/>
<exclude name="com/samskivert/swing/**" unless="build.swing"/>
<exclude name="com/samskivert/test/**" unless="build.test"/>
<exclude name="com/samskivert/util/**" unless="build.util"/>
<exclude name="com/samskivert/velocity/**" unless="build.velocity"/>
<exclude name="com/samskivert/xml/**" unless="build.xml"/>
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
<compilerarg value="-Xlint:-deprecation"/>
</javac>
</target>
<!-- run the tests -->
<target name="test" depends="compile" description="Run tests.">
<taskdef name="unit" classpathref="classpath"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
<unit printsummary="off" haltonfailure="yes" fork="${junit.fork}">
<classpath refid="classpath"/>
<sysproperty key="test_dir" value="${basedir}"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${src.dir}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</unit>
</target>
</project>