ant+junit执行自动化并且生成report报告 话不多说,直接上代码
<?xml version="1.0" encoding="UTF-8"?>
<project name="AntDemo" default="junit" basedir=".">
<property name="src.path" value="src" />
<property name="build.path" value="build" />
<property name="test.path" value="src/service/util" />
<property name="lib.path" value="lib" />
<property name="report.path" value="report" />
<path id="compile.path">
<fileset dir="${lib.path}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${lib.path}/junit">
<include name="**/*.jar" />
</fileset>
<pathelement path="${build.path}" />
</path>
<target name="clean" description="clean">
<delete dir="${build.path}" />
<delete dir="${report.path}" />
</target>
<target name="compile" depends="clean" description="compile">
<mkdir dir="${build.path}" />
<javac srcdir="${src.path}" destdir="${build.path}" classpathref="compile.path" />
</target>
<target name="junit" depends="compile">
<mkdir dir="${report.path}" />
<junit printsummary="true" fork="true">
<formatter type="xml" usefile="true" />
<classpath refid="compile.path" />
<batchtest fork="on" todir="${report.path}" haltonfailure="no">
<fileset dir="${build.path}">
<include name="**/*yTest.class" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${report.path}">
<fileset dir="${report.path}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.path}" />
</junitreport>
</target>
</project>