一、问题一 支持ANT的<junit>任务所需的jar包的配置。
Note: This task depends on external libraries not included in the Ant distribution. See Library Dependencies for more information.
注意:JUnit这个人物依赖于可选的库,不包括在标准ant.jar中。
Note: You must have junit.jar and the class files for the <junit> task in the same classpath. You can do one of:
注意:你必须拥有junit.jar,并且这个类文件必须在同一个ant路径下
Put both junit.jar and the optional tasks jar file in ANT_HOME/lib.
1,把junit.jar和可选任务jar(optional.jar) 文件放进ANT_HOME/lib目录中。环境变量ANT_HOME = **\ant 这样的目录。
Do not put either in ANT_HOME/lib, and instead include their locations in your CLASSPATH environment variable.
2,如果不把junit.jar和可选任务jar(optional.jar) 文件放进ANT_HOME/lib目录中,那么可以这样做: 把这两个jar文件的绝对路径(包括文件名)写进你的系统环境变量CLASSPATH中。
Do neither of the above, and instead, specify their locations using a <classpath> element in the build file. See the FAQ for details.
3,如果你不想做上面那2个办法,那么,你可以这样:
在构造文件ant中,使用<classpath>元素,指定junit.jar和可选任务jar(optional.jar) 文件的位置。
下面是成功的例子:
<?xml version="1.0"?>
<project name="project" default="junit">
<property name="run.classpath" value="bin"></property>
<property name="run.srcpath" value="src"></property>
<property name="test.srcpath" value="test"></property>
<property name="test.report" value="report"></property>
<property name="lib.dir" value="lib"/>
<path id="compile.path">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- Compilation Classpath
<path id="compile.classpath">
<fileset dir="${telecom_LDBS.lib}">
<include name="**/*.jar"/>
</fileset>
</path>
-->
<target name="compile">
<javac destdir="${run.classpath}" srcdir="${run.srcpath}"
classpathref="compile.path"/>
<javac destdir="${run.classpath}" srcdir="${test.srcpath}"
classpathref="compile.path"/>
</target>
<target name="junit" depends="compile">
<tstamp/>
<mkdir dir="${test.report}"/>
<mkdir dir="${test.report}/framework-${DSTAMP}-${TSTAMP}"/>
<junit printsummary="true">
<classpath >
<pathelement path="${run.classpath}"/>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<!--
<test name="Ldbs1AdslSectionBaseinfoModelServiceTest"></test>
-->
<formatter type="plain"/>
<!-- she zhi yao ce shi de wen jian ji he .-->
<batchtest fork="yes" todir="${test.report}/framework-${DSTAMP}-${TSTAMP}">
<fileset dir="${test.srcpath}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
</project>