ant+testng 搭建
<?xml version="1.0" encoding="UTF-8"?>
<!-- one project with multiple targets -->
<project name="juzilicai" default="autotest" basedir=".">
<!-- paths used -->
<property name="src.dir" value="src" />
<property name="conf.dir" value="conf" />
<property name="dest.dir" value="build" />
<property name="dest.report" value="report" />
<path id="jarfile">
<fileset dir="lib" includes="selenium-server-standalone-2.46.0.jar" />
<fileset dir="lib" includes="testng-6.8.5.jar" />
<fileset dir="lib" includes="ant-1.7.1.jar" />
<fileset dir="lib" includes="reportng-1.1.4.jar" />
</path>
<!-- delete the output folder if it exists -->
<delete dir="${dest.dir}" failonerror="false" />
<!-- create the output folder -->
<mkdir dir="${dest.dir}" />
<mkdir dir="${dest.report}" />
<mkdir dir="${conf.dir}" />
<!-- target to compile all test classes out -->
<target name="build" description="执行TestNg测试用例">
<!-- do copy -->
<copy todir="${dest.dir}/conf">
<fileset dir="${conf.dir}" />
</copy>
<!-- compile -->
<javac srcdir="${src.dir}" destdir="${dest.dir}" encoding="UTF-8" includeantruntime="on" debug="true" fork="yes">
<classpath refid="jarfile" />
</javac>
</target>
<!-- define the TestNG task -->
<taskdef name="testng" classname="com.beust.testng.TestNGAntTask" classpathref="jarfile" />
<!-- run test cases for FF -->
<target name="autotest" depends="build">
<testng classpathref="jarfile" outputDir="${dest.report}" haltOnFailure="true" useDefaultListeners="false">
<classfileset dir="${dest.dir}" includes="*.class" />
<classpath>
<pathelement path="${dest.dir}" />
</classpath>
<xmlfileset dir="${basedir}" includes="${src.dir}/testng.xml" />
<sysproperty key="org.uncommons.reportng.title" value="自动化测试报告" />
</testng>
</target>
</project>
附工程结构图
转载于:https://my.oschina.net/ywyw/blog/680873