我理解你的问题,因为你只想在另一台机器上运行Junit测试,而无需实际构建它?您可以将下面的行作为Cruise控件的构建脚本,也可能是Hudson的构建脚本
如果您通过ant使用该任务,则遵循与标准构建相同的原则。您可以从源代码管理中检出所有目标机器的代码。
将所有根目录外部化为build.properties。这些属性必须像这样在每台机器上设置。
#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也会有一些相对于上面定义的静态属性。这些不需要任何用户在任何本地机器上进行更改。
ear.dist.dir = ${root.project.dir}/target
src.dir = ${root.project.dir}/src
test.src.dir = ${root.project.dir}/test
确保您的build.xml仅指通过这些属性的任何进一步的子目录没有任何硬编码值。
我的junit是在由
<import file="${root.project.dir.buildscripts.dir}/junit.xml"/>
导入的build.xml和junit.xml的某些部分被示出在下面
<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>
您几乎可以说我想要的是不可能对build.xmls进行更改。接受的答案,因为它有足够的解释关于如何构建构建文件。谢谢! – Jayan 2010-09-26 16:29:37