I understand your question as you want to only run the Junit tests on another machine without actually building on it? You can run something on the lines below as build scripts from Cruise control and probably Hudson too
If you're using the task via ant, then follow the same principles as a standard build. You can check out the code to all target machines from source control.
Externalize all root directories to a build.properties. These are properties which have to be set on each machine like so.
#Overall Project Name
project.name=myapp
# Top Level Root directory of the new working project
toplevel.project.dir=D:/proj/eComm
# Root directory of the source code
root.project.dir=D:/proj/eComm/Construction
# JDK home directory
jdk.home=C:/jdk1.5.0_11
build.properties will also have some static properties defined relative to the above. These need not be changed by any user on any local machine.
ear.dist.dir = ${root.project.dir}/target
src.dir = ${root.project.dir}/src
test.src.dir = ${root.project.dir}/test
Ensure your build.xml only refers to any further sub directories via these properties without any hardcoded values in it.
My junit are in a separate file which is imported into the build.xml by
<import file="${root.project.dir.buildscripts.dir}/junit.xml"/>
and some part of junit.xml is shown below
<target name="run.junit" depends="clean.junit, junit.info, prepare.junit"
description="Compiles and runs all JUnit Tests in the 'test' directory and produces a report of all failures">
<junit printsummary="yes" fork="true" haltonfailure="no" showoutput="yes" maxmemory="512m">
<jvmarg line="${junit.jvm.arg}"/>
<classpath>
<fileset dir="${src.dir}">
<include name="**/*.*"/>
</fileset>
<fileset dir="${ear.dist.dir}/build/classes">
<include name="**/*.*"/>
</fileset>
<pathelement path="${test.run.path}"/>
</classpath>
<formatter type="xml"/>
<batchtest fork="true" todir="${ear.dist.dir}/build/junit">
<fileset dir="${test.src.dir}" includes="${test.pattern.include}"/>
</batchtest>
</junit>
</target>