make build with Ant and Junit and generate a html Report.
[for specific: go through the Ant Tutorial on official websites]
build.xml [project name is “sele”]
<?xml version="1.0"?>
<project name="sele" default="junit">
<property name="bin.dir" value="bin"></property>
<property name="src.dir" value="src"></property>
<property name="xml.dir" value="xml"></property>
<property name="report.dir" value="report"></property>
<property name="lib.dir" value="lib"/>
<path id="compiletool">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="init">
<delete dir="${report.dir}"/>
<mkdir dir="${report.dir}"/>
<delete dir="${xml.dir}"/>
<mkdir dir="${xml.dir}"/>
</target>
<target name="compile" depends="init">
<javac destdir="${bin.dir}" srcdir="${src.dir}"
classpathref="compiletool" includeantruntime="on"/>
</target>
<target name="junit" depends="compile">
<junit printsummary="yes">
<classpath path="${bin.dir}"></classpath>
<formatter type="xml"/>
<batchtest todir="${xml.dir}">
<fileset dir="${bin.dir}">
<include name="**/TestLogin.class"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${xml.dir}">
<fileset dir="${xml.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${report.dir}"/>
</junitreport>
</target>
</project>
注意:还需要把junit.jar包,手工拷贝到ANT_HOME\lib下面才可以让ant正确执行junit测试.(或者把junit.jar包也放进工程的lib里面作为classpath)
否则会导致BUILD FAILED: The classpath for junit must include junit.jar if not in Ant's own classpath.