build-testNG.xml对应的ant脚本为

<?xml version="1.0" encoding="UTF-8"?>
<project default="coverage-report"> <property name="src.dir" location="src"></property>
<property name="test.src.dir" location="test"></property>
<property name="web.dir" location="WebRoot"></property>
<property name="conf.dir" location="conf"></property>
<property name="web.web-info.dir" location="${web.dir}/WEB-INF"></property>
<property name="lib.dir" location="${web.web-info.dir}/lib"></property>
<property name="build.dir" location="build"></property>
<property name="build.classes" location="${build.dir}/classes"></property>
<property name="test.dir" location="${build.dir}/test/"></property>
<property name="test.classes.dir" location="${test.dir}/classes"></property>
<property name="test.report.dir" location="${test.dir}/test-report"></property>
<property name="build.jar.dir" location="${build.dir}/dist"></property>
<property name="build.zip.dir" location="${build.dir}/zip"></property>
<property name="build.doc.dir" location="${build.dir}/doc"></property>
<property name="build.src" location="${build.dir}/src"></property>
<property name="instrumented_classes" value="${test.dir}/instrumented-classes" />
<property name="cobertura_report" value="${test.dir}/cobertura-report" /> <path id="complie-path">
<fileset dir="${lib.dir}" includes="**/*.jar"></fileset>
</path> <path id="complie-test-path">
<path refid="complie-path"></path>
<pathelement location="${build.classes}"/>
</path> <path id="run-test-path">
<path refid="complie-test-path"></path>
<pathelement location="${test.classes.dir}"/>
</path> <path id="cobertura-run-path">
<path refid="complie-path"></path>
<pathelement location="${test.classes.dir}"/>
<pathelement location="${instrumented_classes}"/>
</path>
<taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="complie-path" />
<target name="clean">
<delete dir="${build.dir}"></delete>
</target> <target name="init" depends="clean" >
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes}"/>
<mkdir dir="${test.dir}"/>
<mkdir dir="${test.classes.dir}"/>
<mkdir dir="${test.report.dir}"/>
<mkdir dir="${build.jar.dir}"/>
<mkdir dir="${build.zip.dir}"/>
<mkdir dir="${build.doc.dir}"/>
<mkdir dir="${build.src}"/>
<mkdir dir="${instrumented_classes}"/>
<mkdir dir="${cobertura_report}"/>
</target> <target name="compile" depends="init">
<javac destdir="${build.classes}" srcdir="${src.dir}" includeantruntime="true"
classpathref="complie-path">
</javac> <copy todir="${build.classes}" >
<fileset dir="${src.dir}" excludes="**/*.java"></fileset>
</copy>
</target> <target name="compile-test" depends="compile">
<javac destdir="${test.classes.dir}" srcdir="${test.src.dir}" includeantruntime="true"
classpathref="complie-test-path">
</javac>
<copy todir="${test.classes.dir}" >
<fileset dir="${test.src.dir}" excludes="**/*.java"></fileset>
</copy> </target> <target name="run-test" depends="compile-test">
<testng classpathref="run-test-path" outputDir="${test.report.dir}"
haltonfailure="true"
useDefaultListeners="false"
listeners="org.uncommons.reportng.HTMLReporter,org.testng.reporters.FailedReporter" >
<xmlfileset dir="${src.dir}" includes="testNG.xml"/>
<jvmarg value="-Dfile.encoding=UTF-8" />
<sysproperty key="org.uncommons.reportng.title" value="AutoMation TestReport" />
</testng>
</target> <!-- 定义 cobertura 的ant task -->
<taskdef classpath="cobertura.jar" resource="tasks.properties" classpathref="complie-path" />
<!-- 为源码添加日志代码,放到 instrumented-classes 目录 -->
<target name="instrument" depends="run-test">
<cobertura-instrument todir="${instrumented_classes}">
<fileset dir="${build.classes}">
<include name="**/*.class" />
</fileset>
</cobertura-instrument>
</target> <target name="cover-test" depends="instrument">
<testng classpathref="run-test-path" outputDir="${test.report.dir}"
haltonfailure="true"
useDefaultListeners="false"
listeners="org.uncommons.reportng.HTMLReporter,org.testng.reporters.FailedReporter" >
<xmlfileset dir="${src.dir}" includes="testNG.xml"/>
<jvmarg value="-Dfile.encoding=UTF-8" />
<sysproperty key="org.uncommons.reportng.title" value="AutoMation TestReport" />
</testng>
</target> <!-- 输出报告 -->
<target name="coverage-report" depends="cover-test">
<cobertura-report srcdir="${src.dir}" destdir="${cobertura_report}"/>
</target> </project>

最新文章

  1. [转]svn 清理失败 (cleanup 失败) 的解决方法
  2. 协程、异步IO
  3. JS中的this对象详解
  4. Swift语言实战晋级-第9章 游戏实战-跑酷熊猫-4 熊猫的跳和打滚
  5. 详解HTML&lt;head&gt; 头标签元素的意义以及使用场景
  6. Magento模型和ORM基础
  7. AndroidStudio Gradle版本不匹配问题
  8. 贪心算法-找零钱(C#实现)
  9. 10gocm-&amp;gt;session5-&amp;gt;数据库管理实验
  10. c语言字符串转OC字符串
  11. Winscp无法连接linux虚拟机解决
  12. Java8时间的简单时间
  13. Python重新安装pip
  14. A1091. Acute Stroke
  15. c#与wpf的一些基础语法问题(摘用)
  16. @PostConstruct和@PostConstruct 注解 及ehcache 缓存 执行过程 小记
  17. 浏览器中beforeunload的使用
  18. 安装kafka集群
  19. PyCharm使用Github管理代码
  20. 基于pandas python sklearn 的美团某商家的评论分类(文本分类)

热门文章

  1. 服务器开发 Ubuntu
  2. JavaScript ——内部函数和匿名函数
  3. GNS3--cisco路由器NAT配置
  4. Chisel3 - Tutorial - Adder4
  5. rewrite和return的简单需求
  6. ASP.NET中IHttpHandler与IHttpModule的区别(带样例说明)
  7. Java实现 LeetCode 477 汉明距离总和
  8. Java实现 蓝桥杯VIP 算法提高 复数求和
  9. Java实现哥德巴赫猜想
  10. java实现 洛谷 P1056 排座椅