一个ant,junit例子
<?xml version="1.0" ?>
<project name="structured" default="archive" >
<target name="init" description="初始化">
<mkdir dir="build/classes" />
<mkdir dir="dist" />
</target>
<target name="compile" depends="init" description="编译">
<javac srcdir="src" destdir="build/classes"/>
<javac srcdir="src" destdir="WebRoot/WEB-INF/classes"/>
</target>
<target name="exe" depends="compile" description="执行">
<java classname="com.peidw.AntTest" classpath="build/classes" >
<arg value="a"/>
<arg value="B"/>
<arg value="c"/>
</java>
</target>
<target name="test" depends="exe">
<mkdir dir="build/classes/test-classes"/>
<javac srcdir="test" destdir="build/classes/test-classes">
<classpath>
<pathelement location="build/classes"/>
<pathelement location="WebRoot/WEB-INF/lib/*.jar"/>
</classpath>
</javac>
<mkdir dir="build/test-results"/>
<junit haltonfailure="no" printsummary="yes">
<classpath>
<pathelement location="build/classes"/>
<pathelement location="WebRoot/WEB-INF/lib/junit.jar"/>
<pathelement location="build/classes/test-classes"/>
</classpath>
<formatter type="brief" usefile="false"/>
<formatter type="xml" />
<batchtest todir="build/test-results" >
<fileset dir="build/classes/test-classes" includes="**/*Test.class"/>
</batchtest>
</junit>
</target>
<target name="report" depends="test" description="生成报表">
<!-- 用执行以上TestCase生成的报告数据生成测试报告 -->
<mkdir dir="build/test-report"/>
<junitreport todir = "build/test-report">
<fileset dir = "build/test-results">
<include name = "TEST-*.xml" />
</fileset >
<!-- 指定生成测试报告的格式frames/noframes,和报告存放目录 -->
<report format = "frames" todir = "build/test-report" />
</junitreport>
</target>
<target name="archive" depends="report" description="打包">
<jar destfile="dist/project.jar" basedir="build/classes" />
<war destfile="dist/antjunit.war" webxml="WebRoot/WEB-INF/web.xml" basedir="WebRoot"/>
</target>
<target name="clean" depends="init">
<delete dir="build" />
<delete dir="dist" />
</target>
</project>
posted on 2008-06-01 15:31
有猫相伴的日子 阅读(401)
评论(0) 编辑 收藏 所属分类:
QA