cactus.sysproperties=cactus.contextURL
#cactus-sample-servlet-cactified就是你的测试应用所在路径,8080是端口号
cactus.contextURL = http://localhost:8080/cactus-sample-servlet-cactified
cactus.servletRedirectorName = ServletRedirector
cactus.jspRedirectorName = JspRedirector
cactus.filterRedirectorName = FilterRedirector
<path id="project.classpath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<!-- cactus.properties文件就需要放在lib.dir所对应的路径中 -->
<pathelement location="${lib.dir}"/>
<pathelement location="${tomcat.home}/common/lib/jsp-api.jar"/>
<pathelement location="${tomcat.home}/common/lib/servlet-api.jar"/>
</path>
<taskdef resource="cactus.tasks" classpathref="project.classpath"/>
<taskdef name="runservertests" classname="org.apache.cactus.integration.ant.RunServerTestsTask">
<classpath>
<path refid="project.classpath"/>
</classpath>
</taskdef>
<target name="war" depends="compile.java"
description="Generate the runtime war">
<war warfile="${target.dir}/${project.name}.war"
webxml="${src.webapp.dir}/WEB-INF/web.xml">
<fileset dir="${src.webapp.dir}">
<exclude name="cactus-report.xsl"/>
<exclude name="WEB-INF/cactus-web.xml"/>
<exclude name="WEB-INF/web.xml"/>
</fileset>
<classes dir="${target.classes.java.dir}"/>
<!-- 别忘了打包测试类 -->
<classes dir="${target.classes.test.dir}"/>
<!-- 别忘了打包各种相关的jar文件 -->
< lib dir="project.classpath"/>
</war>
</target>
<target name="test.prepare"
depends="war, compile.cactus, test.prepare.logging">
<!-- Cactify the web-app archive -->
<cactifywar srcfile="${target.dir}/${project.name}.war"
destfile="${tomcat.home}/webapps/${project.name}-cactified.war"
>
<classes dir="${target.classes.java.dir}"/>
<classes dir="${target.classes.test.dir}"/>
<lib dir="project.classpath"/>
</cactifywar>
</target>
<target name="test" depends="test.prepare"
description="Run tests on Tomcat ">
<!-- Start the servlet engine, wait for it to be started, run the
unit tests, stop the servlet engine, wait for it to be stopped.
The servlet engine is stopped if the tests fail for any reason -->
<!-- 8080是服务器的端口号,${project.name}-cactified是项目的路径,和上一步的cactifywar 的destfile相对应 -->
<runservertests
testURL="http://localhost:8080/${project.name}-cactified/ServletRedirector?Cactus_Service=RUN_TEST"
startTarget="_StartTomcat"
stopTarget="_StopTomcat"
testTarget="_Test"/>
</target>
<!-- _Test就是一个普通的junit任务 -->
<target name="_Test">
<junit printsummary="yes" fork="yes">
<classpath>
<path refid="project.classpath"/>
<pathelement location="${target.classes.java.dir}"/>
<pathelement location="${target.classes.test.dir}"/>
</classpath>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest>
<fileset dir="${src.test.dir}">
<!-- Due to some Cactus synchronization bug, the 'unit' tests need
to run before the 'sample' tests -->
<include name="**/Test*.java"/>
<exclude name="**/Test*All.java"/>
</fileset>
</batchtest>
</junit>
</target>
0
顶一下0
踩一下