A template build.xml for running junit test by ant
2009-06-25 16:16
393 查看
Here is a template, you can modify the project name and replace the classpath with your own classpath.
<?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="runtests" name="AllocatedPart"> <!-- project common properties --> <property name="app.name" value="AllocatedPart" /> <property name="allocatedpart.home" value="." /> <!-- build related --> <property name="build.dir" value="${allocatedpart.home}/build" /> <property name="classes.dir" value="${build.dir}/src" /> <property name="test.dir" value="${build.dir}/test" /> <property name="src" value="src" /> <property name="test" value="test" /> <!-- library --> <property name="lib.dir" value="${allocatedpart.home}/../lib" /> <property name="distributed.dir" value="${allocatedpart.home}/../distributed" /> <property name="thirdlib.dir" value="E:/libs" /> <!-- environment --> <property environment="env" /> <!-- junit check --> <target name="junit"> <available property="junit.present" classname="junit.framework.TestCase" /> </target> <!-- project classpath --> <path id="project.class.path"> <fileset dir="${lib.dir}"> <include name="**/*.jar" /> </fileset> <fileset dir="${distributed.dir}"> <include name="**/*.jar" /> </fileset> <fileset dir="${thirdlib.dir}/spring2.0"> <include name="**/*.jar" /> </fileset> <fileset dir="${thirdlib.dir}/strutstest"> <include name="**/strutstest.jar" /> </fileset> <fileset dir="${thirdlib.dir}/struts/struts1.3.8"> <include name="**/*.jar" /> </fileset> <fileset dir="${thirdlib.dir}/common"> <include name="**/*.jar" /> </fileset> </path> <!-- copy applicationContext*.xml --> <target name="resource"> <copy todir="${test.dir}"> <fileset dir="${test}"> <include name="**/*.xml" /> <!-- other type of files can also be included here --> </fileset> </copy> </target> <!-- clean the build artifacts --> <target name="clean"> <delete failonerror="false" includeemptydirs="true"> <fileset dir="${build.dir}" /> </delete> </target> <!-- compile the source code --> <target name="compile" depends="junit"> <mkdir dir="${classes.dir}" /> <javac classpathref="project.class.path" debug="true" destdir="${classes.dir}" nowarn="false"> <classpath> <pathelement location="${weblogic8.dir}/server/lib/weblogic.jar" /> </classpath> <src path="${src}" /> <exclude name="**/CVS/**" /> </javac> </target> <!-- package the source code to jar --> <target name="jar" depends="compile"> <mkdir dir="${build.dir}" /> <jar jarfile="${build.dir}/${app.name}.jar" basedir="${classes.dir}" includes="com/**" /> </target> <!-- compile the test case source code --> <target name="compiletests" depends="jar"> <mkdir dir="${test.dir}" /> <javac srcdir="${test}" classpathref="project.class.path" destdir="${test.dir}"> <classpath> <pathelement location="${build.dir}/${app.name}.jar" /> </classpath> <include name="**/*.java" /> </javac> </target> <!-- run the test cases --> <target name="runtests" depends="clean,compiletests,resource" if="junit.present"> <java fork="yes" classpathref="project.class.path" classname="junit.textui.TestRunner" taskname="junit" failonerror="true"> <arg value="com.synnex.cis.part.biz.ValueListTest" /> <classpath> <pathelement location="${build.dir}/${app.name}.jar" /> <pathelement location="${test.dir}" /> </classpath> </java> </target> </project>
相关文章推荐
- junit与ant整合的build.xml的编写-----非常重要,看懂这个,你就懂了ant的90%了
- build.xml for junit
- How do I set file.encoding for a junit test in ant?
- How do I set file.encoding for a junit test in ant?
- How do I set file.encoding for a junit test in ant?
- Ant build.xml 模版 (JUnit)自动化 增量测试
- ANT build.xml 编译出错Error running javac.exe compiler
- ANT build.xml 编译出错Error running javac.exe compiler
- build.xml sample for ant
- Running JUnit test in Spring MVC throws: org.xml.sax.SAXParseException; systemId: http://www.springf
- Ant系列-第一个build.xml
- android-sdk-linux/tools/ant/build.xml:401: SDK Platform Tools component is missing. Please install i
- 【studio导入module遇到问题一】:Gradle build-info.xml not found for moudle..Please make sure..gradle plugin
- 2.扩展ant,对文件内容的行进行排序:build.xml
- Builds Details by Device for Engineering (DownLoad to PC,Field Type=CSV)
- Ant 打包war 生成文件内容build.xml
- Ant---build.xml
- Ant build.xml文件详解
- ANT - build.xml
- 用 ant 把一个web项目打成war 不依赖eclipse build.xml