<project name="AUTO_TEST" basedir="." default="run_tests">
<property name="src" value="src" />
<property name="dest" value="classes" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="output.dir" value="${basedir}/test-output" />
<!--<property name="testcase" value="${src}/com/selenium/testcase" />-->
<path id="compile.path">
<fileset dir="${lib.dir}/">
<include name="*.jar" />
</fileset>
<pathelement location="${src}" />
<pathelement location="${dest}" />
</path>
<target name="init">
<mkdir dir="${dest}" />
<!--<delete dir="${dest}"></delete>
<delete dir="${testcase}"></delete>
<mkdir dir="${dest}" />-->
</target>
<target name="compile" depends="init">
<echo>compile tests</echo>
<javac srcdir="${src}" destdir="${dest}" encoding="UTF-8"
classpathref="compile.path" />
</target>
<!-- <target name="run" depends ="compile">
<java classname ="Proxy">
<classpath>
<pathelement path="${dest}/com/selenium/util"/>
</classpath>
</java>
</target>-->
<taskdef resource="testngtasks" classpath="${lib.dir}/testng-6.8.5.jar" />
<!-- <taskdef name="testng" classname="${dest}/org.testng.TestNGAntTask"/>-->
<!-- 开始测试 -->
<target name="run_tests" depends="compile">
<echo>running tests</echo>
<testng classpathref="compile.path" outputdir="${output.dir}"
haltonfailure="no"
failureproperty="failed"
parallel="true"
useDefaultListeners="true"
listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter"
threadCount="3" >
<xmlfileset dir="${basedir}/src/com/selenium" includes="TestNG1.xml" />
<classfileset dir="${dest}">
<include name="/*.class" />
</classfileset>
<sysproperty key="org.uncommons.reportng.title" value="My Test Report"/>
</testng>
<!--<antcall target="transform1" />-->
<!-- <fail message="TEST FAILURE" if="failed" /> -->
</target>
<target name="transform1" description="report">
<testng classpathref="compile.path"
outputdir="${output.dir}"
haltonfailure="true"
useDefaultListeners="false"
listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter">
<xmlfileset dir="${basedir}/src/com/selenium" includes="TestNG1.xml"/>
<sysproperty key="org.uncommons.reportng.title" value="My Test Report"/>
</testng>
</target>
<!-- 生成报告 -->
<target name="transform" description="report">
<xslt
in="${output.dir}/testng-results.xml"
style="${output.dir}/testng-results.xsl"
out="${output.dir}/Report.html"
force="yes">
<!-- you need to specify the directory here again -->
<param name="testNgXslt.outputDir" expression="${output.dir}" />
<classpath refid="compile.path" />
</xslt>
</target>
</project>