当前位置:七道奇文章资讯编程技术Java编程
日期:2011-03-22 16:13:00  来源:本站整理

用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编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:

  • 利用antixss防备xss
  • 用Ant自动测试JUnit
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .