51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 2052|回复: 0
打印 上一主题 下一主题

[JUnit&Ant]编译运行并生成html报告的ant脚本

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2008-12-23 15:10:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在Eclipse创建一个项目
在项目中再创建一个lib的文件夹
在项目中创建一个xml文件,名称为build

以下为文件内容:
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <project basedir="." name="TestGPro" default="junit">
  3.         <property name="run.classpath" value="bin">
  4.         </property>
  5.         <property name="run.srcpath" value="src">
  6.         </property>
  7.         <property name="test.srcpath" value="src">
  8.         </property>
  9.         <property name="test.report" value="report">
  10.         </property>
  11.         <property name="lib.dir" value="lib">
  12.         </property>
  13.         <path id="compile.path">
  14.                 <fileset dir="${lib.dir}">
  15.                         <include name="**/.*jar" />
  16.                 </fileset>
  17.         </path>

  18.         <target name="compile">
  19.                 <javac destdir="${run.classpath}" srcdir="${run.srcpath}" classpathref="compile.path">
  20.                 </javac>
  21.         </target>
  22.         <target name="junit" depends="compile">
  23.                 <tstamp>
  24.                 </tstamp>
  25.                 <mkdir dir="${test.report}" />
  26.                 <mkdir dir="${test.report}" />

  27.                 <!-- 测试代码 -->
  28.                 <junit printsummary="true">
  29.                         <formatter type="xml" />
  30.                         <classpath>
  31.                                 <pathelement path="${run.classpath}" />
  32.                                 <fileset dir="${lib.dir}">
  33.                                         <include name="**/*.jar" />
  34.                                 </fileset>
  35.                         </classpath>
  36.                         <formatter type="plain" />
  37.                         <batchtest todir="${test.report}">
  38.                                 <fileset dir="${test.srcpath}">
  39.                                         <include name="**/*Test.java" />
  40.                                 </fileset>
  41.                         </batchtest>
  42.                 </junit>

  43.                 <!-- 生成测试报告 -->

  44.                 <junitreport todir="${test.report}">

  45.                         <fileset dir="${test.report}">
  46.                                 <include name="TEST-*.xml" />
  47.                         </fileset>
  48.                         <report format="frames" todir="${test.report}" />
  49.                 </junitreport>
  50.         </target>
  51. </project>
复制代码

[ 本帖最后由 csgood 于 2008-12-24 13:56 编辑 ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-5-3 19:20 , Processed in 0.070528 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表