ant集成junit自动测试的build.xml标准模板
来源:互联网 发布:淘宝家具类目如何操作 编辑:程序博客网 时间:2024/05/21 16:04
利用Ant集成Junit自动测试并生成测试报告,可以极大的提高测试的工作效率,其优势只要是测试用例的批量处理功能。前不久在网上看到很多关于Junit测试的文章,欣闻Ant支持Junit的集成,迫不及待的尝试了一番。
1. ant的配置:
本案例采用apache-ant-
2. 目录结构:
工作目录
|-src-|—com-|—wallace-|-Calculator.java
|-test-|-TestCalculator.java
|-lib-|-junit.jar
|-build
|-report
3. build.xml模板:
<?xml version="1.0" encoding="utf-8"?>
<project name="test" default="test" basedir=".">
<!--配置基本属性-->
<property name="src" value="src"/>
<property name="build" value="build"/>
<property name="lib" value="lib" />
<property name="dist" value="dist"/>
<property name="classpath" location="${build}"/>
<!--配置测试报告的属性-->
<property name="report" value="report"/>
<property name="report.xml" value="${report}/junit/xml"/>
<property name="report.html" value="${report}/junit/html"/>
<!--配置运行时classpath-->
<path id="classpath.run">
<pathelement path="${classpath}"/>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</path>
<!--配置测试时classpath-->
<path id="classpath.test">
<path refid="classpath.run"/>
<path location="${dist}/lib/test-${DSTAMP}.jar"/>
</path>
<!--任务初始化-->
<target name="init" >
<tstamp/>
<delete dir="${build}"/>
<delete dir="${report}"/>
<delete dir="${dist}"/>
<mkdir dir="${build}"/>
</target>
<!--配置编译任务-->
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${build}">
<classpath refid="classpath.run" />
</javac>
</target>
<!--配置打包任务-->
<target name="dist" depends="compile">
<mkdir dir="${dist}/lib"/>
<jar jarfile="${dist}/lib/test-${DSTAMP}.jar" basedir="${build}"/>
</target>
<!--配置运行任务-->
<target name="run" depends="compile, dist">
<java classname="com.test.TestCalculator">
<classpath>
<path refid="classpath.run"/>
</classpath>
</java>
</target>
<!--配置JUnit测试,打印测试结果-->
<target name="test" depends="compile, dist">
<mkdir dir="${report.xml}"/>
<mkdir dir="${report.html}"/>
<junit printsummary="yes" haltonfailure="no">
<classpath refid="classpath.run"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${report.xml}">
<fileset dir="${src}" includes="**/Test*.java"/>
</batchtest>
</junit>
<junitreport todir="${report.html}">
<fileset dir="${report.xml}">
<include name="*.xml"/>
</fileset>
<report format="frames" todir="${report.html}"/>
</junitreport>
</target>
</project>
- ant集成junit自动测试的build.xml标准模板
- 转: ant集成junit自动测试的build.xml标准模板
- Ant集成Junit实现自动化测试的Build.xml模板详解
- Ant build.xml 模版 (JUnit)自动化 增量测试
- Ant build.xml 模板
- Ant build.xml (模板)
- ant build.xml模板
- 常用的Ant模板(BUILD.XML)
- 常用的Ant模板(BUILD.XML)
- 常用的Ant模板(BUILD.XML)
- Ant的build.xml脚本模板
- Eclipse 自动生成 Ant的Build.xml
- JUnit+ANT自动测试实验
- Apache Ant编写build.XML的自动提示 ANT DTD
- Ant 自动构建 build.xml
- Ant的build.xml
- Ant 使用Junit自动测试要注意的问题
- ant build.xml 之 tomcat工程的通用模板
- Spring AOP框架
- 如何规划职业发展道路——给软件从业人员的建议
- 介绍几个ASP.NET中容易忽略但却很重要的方法函数
- 2006.07.26
- 一个小程序的调试过程——源程序注释过滤器
- ant集成junit自动测试的build.xml标准模板
- ASP.NET生成静态网页的方法
- ASP VBScript 动态包含文件, FSO 实现 By Shawl.qiu
- linux下软件的基本安装和卸载
- 取得字符串以特定的分割符的第几个字符
- 感情生活体味
- 最爱班得瑞
- 显示桌面图标找回
- 如何创建数据库Web Services