持续集成环境搭建(hudson+ant+JUNIT+EMMA)<2>之ant脚本
来源:互联网 发布:重庆淘宝客服招聘 编辑:程序博客网 时间:2024/06/05 03:22
<?xml version="1.0" encoding="UTF-8"?>
<project name="TestActivityPlatform" default="all" basedir=".">
<!--设置Java类被注入字节码后存放的路径-->
<property name="bin.instrument.dir" location="${basedir}/instrbin" />
<!--设置覆盖率元数据和报告的路径-->
<property name="coverage.dir" location="${basedir}/coverage" />
<!--设置junit报告的路径 -->
<property name="junitReport.html.dir" location="${basedir}/junitReport/html" />
<property name="junitReport.xml.dir" location="${basedir}/junitReport/xml" />
<!-- 日志 目录-->
<property name="logs.dir" location="${basedir}/logs" />
<!--设置主代码编译文件存放路径-->
<property name="realesBin.dir" location="${basedir}/realesBin" />
<!--设置主代码编译文件存放路径-->
<property name="war.dir" location="${basedir}/war" />
<!--设置测试代码编译文件路径-->
<property name="testBin.dir" location="${basedir}/testBin" />
<!--设置主题代码源路径-->
<property name="src.main.dir" location="${basedir}/src" />
<!--设置测试代码源路径-->
<property name="src.test.dir" location="${basedir}/src" />
<!--设置引用包的位置-->
<property name ="libs" value ="${basedir}/webapp/WEB-INF/lib"/>
<!--指示需要注入字节码的Java类的路径-->
<path id="classpath.main">
<pathelement location="${realesBin.dir}" />
</path>
<!--指示 emma.jar 和emma_ant.jar 的路径-->
<path id="emma.lib">
<pathelement location="${libs}/emma.jar" />
<pathelement location="${libs}/emma_ant.jar" />
</path>
<path id="libPath">
<fileset dir="${libs}">
<include name="*.jar"/>
</fileset>
</path>
<!--允许emma-->
<property name="emma.enabled" value="true" />
<!--为ANT添加EMMA任务-->
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<target name="init">
<delete dir="${bin.instrument.dir}"/>
<delete dir="${coverage.dir}"/>
<delete dir="${junitReport.html.dir}"/>
<delete dir="${junitReport.xml.dir}"/>
<delete dir="${realesBin.dir}"/>
<delete dir="${testBin.dir}"/>
<delete dir="${war.dir}"/>
<delete dir="${logs.dir}"/>
<mkdir dir="${logs.dir}" />
</target>
<target name="compile-src.main">
<mkdir dir="${realesBin.dir}" />
<javac srcdir="${src.main.dir}" destdir="${realesBin.dir}" includeantruntime="on" compiler="javac1.6" source="1.6" encoding="UTF-8" debug="on">
<classpath location="${realesBin.dir}"/>
<classpath refid="libPath"/>
</javac>
<copydir dest="${realesBin.dir}/config" src="${src.main.dir}/config">
</copydir>
<copy todir="${realesBin.dir}" overwrite="true">
<fileset dir="${src.main.dir}">
<include name="*.*"/>
</fileset>
</copy>
</target>
<!--对编译在路径bin.main.dir中的Java类注入字节码, 并且把注入字节码的新Java类存放到路径bin.instrument.dir-->
<!--覆盖率的元数据存放在路径coverage.dir中-->
<target name="instrument">
<mkdir dir="${bin.instrument.dir}" />
<mkdir dir="${coverage.dir}" />
<emma enabled="${emma.enabled}">
<instr instrpathref="classpath.main" destdir="${bin.instrument.dir}" metadatafile="${coverage.dir}/metadata.emma" merge="true">
</instr>
</emma>
<copy todir="${bin.instrument.dir}">
<fileset dir="${realesBin.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
<copydir dest="${bin.instrument.dir}/config" src="${src.main.dir}/config">
</copydir>
<copy todir="${bin.instrument.dir}" overwrite="true">
<fileset dir="${src.main.dir}">
<include name="*.*"/>
</fileset>
</copy>
</target>
<!--执行测试用例同时生成junit测试报告和emma代码覆盖率报告-->
<target name="test">
<mkdir dir="${junitReport.html.dir}" />
<mkdir dir="${junitReport.xml.dir}" />
<junit fork="true" forkmode="once" printsummary="yes" errorproperty="test.error" showoutput="on">
<!--指明代码覆盖率的元数据的存放位置-->
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/metadata.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<classpath location="${bin.instrument.dir}"/>
<classpath refid="libPath"/>
<classpath refid="emma.lib" />
<formatter type="xml" />
<!--执行所ProjectAllTest.class的junit测试用例-->
<batchtest todir="${junitReport.xml.dir}" haltonfailure="no">
<fileset dir="${bin.instrument.dir}">
<include name="**/ProjectAllTest.class" />
</fileset>
</batchtest>
</junit>
</target>
<target name="gen-report-junit">
<!--生成junit测试报告-->
<junitreport todir="${junitReport.html.dir}">
<fileset dir="${junitReport.xml.dir}">
<include name="*.xml"/>
</fileset>
<report format="frames" todir="${junitReport.html.dir}" />
</junitreport>
</target>
<!--生成代码覆盖率报告-->
<target name="gen-report-coverage">
<!--如果属性emma.enabled的值是true,就生成代码覆盖率报告 -->
<emma enabled="${emma.enabled}">
<report sourcepath="${src.main.dir}"
sort="+block,+name,+method,+class"
metrics="method:70,block:80,line:80,class:100">
<fileset dir="${coverage.dir}">
<include name="*.emma" />
</fileset>
<html outfile="${coverage.dir}/coverage.html"
depth="method" columns="name,class,method,block,line" encoding="utf-8"/>
<xml outfile="${coverage.dir}/coverage.xml"/>
</report>
</emma>
</target>
<target name ="war" depends="compile-src.main">
<mkdir dir="${war.dir}"/>
<war destfile ="${war.dir}/TMS.war" webxml ="${basedir}/webapp/WEB-INF/web.xml">
<lib dir ="${libs}">
<exclude name="jsp-api.jar"/>
<exclude name="servlet-api.jar"/>
</lib>
<classes dir ="${realesBin.dir}">
<exclude name="cn/tv189/activityplatform/test/"/>
</classes>
<fileset dir ="${basedir}/webapp">
<include name="pages/*.*"/>
<include name="css/*.*"/>
</fileset>
</war>
</target>
<target name="all" depends="init,compile-src.main,instrument,test,gen-report-coverage,gen-report-junit,war">
</target>
</project>
<project name="TestActivityPlatform" default="all" basedir=".">
<!--设置Java类被注入字节码后存放的路径-->
<property name="bin.instrument.dir" location="${basedir}/instrbin" />
<!--设置覆盖率元数据和报告的路径-->
<property name="coverage.dir" location="${basedir}/coverage" />
<!--设置junit报告的路径 -->
<property name="junitReport.html.dir" location="${basedir}/junitReport/html" />
<property name="junitReport.xml.dir" location="${basedir}/junitReport/xml" />
<!-- 日志 目录-->
<property name="logs.dir" location="${basedir}/logs" />
<!--设置主代码编译文件存放路径-->
<property name="realesBin.dir" location="${basedir}/realesBin" />
<!--设置主代码编译文件存放路径-->
<property name="war.dir" location="${basedir}/war" />
<!--设置测试代码编译文件路径-->
<property name="testBin.dir" location="${basedir}/testBin" />
<!--设置主题代码源路径-->
<property name="src.main.dir" location="${basedir}/src" />
<!--设置测试代码源路径-->
<property name="src.test.dir" location="${basedir}/src" />
<!--设置引用包的位置-->
<property name ="libs" value ="${basedir}/webapp/WEB-INF/lib"/>
<!--指示需要注入字节码的Java类的路径-->
<path id="classpath.main">
<pathelement location="${realesBin.dir}" />
</path>
<!--指示 emma.jar 和emma_ant.jar 的路径-->
<path id="emma.lib">
<pathelement location="${libs}/emma.jar" />
<pathelement location="${libs}/emma_ant.jar" />
</path>
<path id="libPath">
<fileset dir="${libs}">
<include name="*.jar"/>
</fileset>
</path>
<!--允许emma-->
<property name="emma.enabled" value="true" />
<!--为ANT添加EMMA任务-->
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<target name="init">
<delete dir="${bin.instrument.dir}"/>
<delete dir="${coverage.dir}"/>
<delete dir="${junitReport.html.dir}"/>
<delete dir="${junitReport.xml.dir}"/>
<delete dir="${realesBin.dir}"/>
<delete dir="${testBin.dir}"/>
<delete dir="${war.dir}"/>
<delete dir="${logs.dir}"/>
<mkdir dir="${logs.dir}" />
</target>
<target name="compile-src.main">
<mkdir dir="${realesBin.dir}" />
<javac srcdir="${src.main.dir}" destdir="${realesBin.dir}" includeantruntime="on" compiler="javac1.6" source="1.6" encoding="UTF-8" debug="on">
<classpath location="${realesBin.dir}"/>
<classpath refid="libPath"/>
</javac>
<copydir dest="${realesBin.dir}/config" src="${src.main.dir}/config">
</copydir>
<copy todir="${realesBin.dir}" overwrite="true">
<fileset dir="${src.main.dir}">
<include name="*.*"/>
</fileset>
</copy>
</target>
<!--对编译在路径bin.main.dir中的Java类注入字节码, 并且把注入字节码的新Java类存放到路径bin.instrument.dir-->
<!--覆盖率的元数据存放在路径coverage.dir中-->
<target name="instrument">
<mkdir dir="${bin.instrument.dir}" />
<mkdir dir="${coverage.dir}" />
<emma enabled="${emma.enabled}">
<instr instrpathref="classpath.main" destdir="${bin.instrument.dir}" metadatafile="${coverage.dir}/metadata.emma" merge="true">
</instr>
</emma>
<copy todir="${bin.instrument.dir}">
<fileset dir="${realesBin.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
<copydir dest="${bin.instrument.dir}/config" src="${src.main.dir}/config">
</copydir>
<copy todir="${bin.instrument.dir}" overwrite="true">
<fileset dir="${src.main.dir}">
<include name="*.*"/>
</fileset>
</copy>
</target>
<!--执行测试用例同时生成junit测试报告和emma代码覆盖率报告-->
<target name="test">
<mkdir dir="${junitReport.html.dir}" />
<mkdir dir="${junitReport.xml.dir}" />
<junit fork="true" forkmode="once" printsummary="yes" errorproperty="test.error" showoutput="on">
<!--指明代码覆盖率的元数据的存放位置-->
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/metadata.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<classpath location="${bin.instrument.dir}"/>
<classpath refid="libPath"/>
<classpath refid="emma.lib" />
<formatter type="xml" />
<!--执行所ProjectAllTest.class的junit测试用例-->
<batchtest todir="${junitReport.xml.dir}" haltonfailure="no">
<fileset dir="${bin.instrument.dir}">
<include name="**/ProjectAllTest.class" />
</fileset>
</batchtest>
</junit>
</target>
<target name="gen-report-junit">
<!--生成junit测试报告-->
<junitreport todir="${junitReport.html.dir}">
<fileset dir="${junitReport.xml.dir}">
<include name="*.xml"/>
</fileset>
<report format="frames" todir="${junitReport.html.dir}" />
</junitreport>
</target>
<!--生成代码覆盖率报告-->
<target name="gen-report-coverage">
<!--如果属性emma.enabled的值是true,就生成代码覆盖率报告 -->
<emma enabled="${emma.enabled}">
<report sourcepath="${src.main.dir}"
sort="+block,+name,+method,+class"
metrics="method:70,block:80,line:80,class:100">
<fileset dir="${coverage.dir}">
<include name="*.emma" />
</fileset>
<html outfile="${coverage.dir}/coverage.html"
depth="method" columns="name,class,method,block,line" encoding="utf-8"/>
<xml outfile="${coverage.dir}/coverage.xml"/>
</report>
</emma>
</target>
<target name ="war" depends="compile-src.main">
<mkdir dir="${war.dir}"/>
<war destfile ="${war.dir}/TMS.war" webxml ="${basedir}/webapp/WEB-INF/web.xml">
<lib dir ="${libs}">
<exclude name="jsp-api.jar"/>
<exclude name="servlet-api.jar"/>
</lib>
<classes dir ="${realesBin.dir}">
<exclude name="cn/tv189/activityplatform/test/"/>
</classes>
<fileset dir ="${basedir}/webapp">
<include name="pages/*.*"/>
<include name="css/*.*"/>
</fileset>
</war>
</target>
<target name="all" depends="init,compile-src.main,instrument,test,gen-report-coverage,gen-report-junit,war">
</target>
</project>
- 持续集成环境搭建(hudson+ant+JUNIT+EMMA)<2>之ant脚本
- 持续集成环境搭建(hudson+ant+JUNIT+EMMA)<1>
- hudson+ant+svn持续集成环境搭建
- 用(Hudson+Subversion+Ant+JUnit)搭建了个持续集成(Continuous Integration)环境
- hudson+ant+svn配置flash持续集成开发环境
- jenkins+ant+svn持续集成环境搭建
- hudson+ant持续集成android项目
- Jenkins+Junit+Ant+Mercurial(hg)+Cobertura+Findbugs (搭建持续集成环境)
- Hudson持续集成环境搭建
- ANT教程之十五 Ant Junit集成
- Cruise+ANT+maven2搭建持续集成环境
- eclipse+Ant+testng+jenkins 持续集成环境的搭建
- 使用CruiseControl+SVN+ANT实现持续集成之二环境搭建和配置介绍
- 使用SVN+CruiseControl+ANT实现持续集成之二----环境搭建和配置介绍
- Jmeter接口持续集成之ANT执行Jmeter脚本
- Hudson+Maven+SVN 搭建持续集成环境
- Hudson+Maven+SVN 搭建持续集成环境
- Hudson+Maven+Svn搭建持续集成环境
- 网络伤感生活日志发布:来不及凋谢的花落
- Java中Set,Map的使用
- linux 安装中文字体
- response.getWriter()的作用
- Android工程报错常见解决方法
- 持续集成环境搭建(hudson+ant+JUNIT+EMMA)<2>之ant脚本
- Eclipse @override报错解决
- 性能测试梳理
- 小弟不才,浅谈关于润乾报表的填报和如何架构!
- xml,jsp文件的注释快捷键
- 男人须知
- ajax的总结
- UBUNTU10.10安装TFTP服务端
- 编写可重入和线程安全的代码