I'm migrating from Netbeans to setup all of my compiling, packaging
and testing. However, I'm having troubles getting the testing part
working. Here's the snippet of code I'm currently using:
<property name="src" value="src"/>
<property name="lib" value="lib"/>
<property name="build" value="build"/>
<property name="dist" value="dist"/>
<property name="dist-lib" value="${dist}/lib"/>
<property name="src.lib.runtime" value="${lib}/runtime"/>
<property name="classes" value="${build}/classes/"/>
<property name="jar.executable" value="${dist}/$
{ant.project.name}.jar"/>
<property name="test.src" value="test"/>
<property name="test.execute" value="${build}/test"/>
<property name="test.reports" value="${test.execute}/reports"/>
<!-- Runs the JUnit Tests -->
<target name="test">
<mkdir dir="${test.reports}"/>
<copy todir="${test.execute}">
<fileset dir="${src}"/>
</copy>
<copy todir="${test.execute}">
<fileset dir="${test.src}"/>
</copy>
<javac srcdir="${test.execute}"
classpath="${classpath}"
debug="true"
source="1.5"
/>
<junit dir="${test.execute}">
<test name="tciworks.analysis.BayesianTest"/>
</junit>
<!--junit printsummary="yes">
<formatter type="plain"/>
<batchtest fork="yes" todir="${test.reports}">
<fileset dir="${test.execute}}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit-->
</target>
Code being tested is in ${src}
Test cases are in ${test.src}.
All of the source is copied to ${test.execute} and compiled there.
When I try to test I get the following (trimmed) error:
Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: build.xml
Detected Java version: 1.5 in: c:\Program Files\Java\jdk1.5.0_06\jre
Detected OS: Windows XP
[antlib

rg.apache.tools.ant] Could not load definitions from resource
org/apache/tools/ant/antlib.xml. It could not be found.
[snip]
test:
[mkdir] Skipping c:\TCIWorks\TCIWorksApplication\build\test
\reports because it already exists.
[copy] tciworks\TCIWorks.java omitted as c:\TCIWorks
\TCIWorksApplication\build\test\tciworks\TCIWorks. java is up to date.
[copy] tciworks\UpdateManager.java omitted as c:\TCIWorks
\TCIWorksApplication\build\test\tciworks\UpdateMan ager.java is up to
date.
[copy] tciworks\analysis\AbstractObjective.java omitted as c:
\TCIWorks\TCIWorksApplication\build\test\tciworks\ analysis
\AbstractObjective.java is up to date.
[snip]
[javac] tciworks\util\TCIFigures.java omitted as c:\TCIWorks
\TCIWorksApplication\build\test\tciworks\util\TCIF igures.class is up
to date.
[javac] tciworks\util\TCISwingWorker.class skipped - don't know
how to handle it
[javac] tciworks\util\TCISwingWorker.java omitted as c:\TCIWorks
\TCIWorksApplication\build\test\tciworks\util\TCIS wingWorker.class is
up to date.
[javac] tciworks\util\TCIWorksConstants.class skipped - don't know
how to handle it
[javac] tciworks\util\TCIWorksConstants.java omitted as c:\TCIWorks
\TCIWorksApplication\build\test\tciworks\util\TCIW orksConstants.class
is up to date.
BUILD FAILED
c:\TCIWorks\TCIWorksApplication\build.xml:134:
java.lang.NullPointerException
at
org.apache.tools.ant.dispatch.DispatchUtils.execut e(DispatchUtils.java:
115)
at org.apache.tools.ant.Task.perform(Task.java:34

at org.apache.tools.ant.Target.execute(Target.java:35 7)
at org.apache.tools.ant.Target.performTasks(Target.ja va:385)
at org.apache.tools.ant.Project.executeSortedTargets( Project.java:
1329)
at org.apache.tools.ant.Project.executeTarget(Project .java:129

at
org.apache.tools.ant.helper.DefaultExecutor.execut eTargets(DefaultExecutor.java:
41)
at org.apache.tools.ant.Project.executeTargets(Projec t.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:69

at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher. java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher .java:104)
Caused by: java.lang.NullPointerException
at org.apache.tools.ant.types.Path.add(Path.java:261)
at
org.apache.tools.ant.taskdefs.optional.junit.JUnit Task.execute(JUnitTask.java:
753)
at org.apache.tools.ant.UnknownElement.execute(Unknow nElement.java:
28

at sun.reflect.GeneratedMethodAccessor2.invoke(Unknow n Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execut e(DispatchUtils.java:
105)
... 11 more
--- Nested Exception ---
java.lang.NullPointerException
at org.apache.tools.ant.types.Path.add(Path.java:261)
at
org.apache.tools.ant.taskdefs.optional.junit.JUnit Task.execute(JUnitTask.java:
753)
at org.apache.tools.ant.UnknownElement.execute(Unknow nElement.java:
28