用Ant自动测试JUnit[Java编程]
本文“用Ant自动测试JUnit[Java编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
1、问题一 支持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>
以上是“用Ant自动测试JUnit[Java编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |