Ant+TestNG+Webdriver环境搭建

来源:互联网 发布:java队列异步任务处理 编辑:程序博客网 时间:2024/05/18 05:57

ANT
1、下载ant,http://ant.apache.org/bindownload.cgi
2、解压
3、配置环境变量
这里写图片描述
这里写图片描述

使用
项目根目录创建build.xml
将项目使用的jar包,拷贝到libs文件夹下

<?xml version="1.0" encoding="UTF-8"?><project basedir="." default="regression" name="automation test">    <property name="base.dir" value="."/>    <property name="testng.output.dir" value="${base.dir}/test-output"/>    <property name="3rd.lib.dir" value="${base.dir}/libs"/>    <property name="testng.file" value="testng.xml"/>    <taskdef resource="testngtasks">          <classpath>              <pathelement location="${3rd.lib.dir}/testng.jar"/> <!--Location为你的contrib包路径-->          </classpath>      </taskdef>    <target name="clean">        <delete dir="${base.dir}/bin"/>    </target>    <target name="compile" depends="clean">        <mkdir dir="${base.dir}/libs"/>        <mkdir dir="${base.dir}/bin"/>        <javac srcdir="${base.dir}/src" destdir="${base.dir}/bin" classpathref="classes" includeantruntime="off" debug="on" debuglevel="lines,vars,source"/>    </target>    <path id="classes">        <fileset dir="${3rd.lib.dir}" includes="*jar"/>        <fileset dir="${3rd.lib.dir}" includes="*zip"/>        <pathelement location="${base.dir}/bin"/>    </path>    <target name="regression" depends="compile">        <testng outputdir="${testng.output.dir}" classpathref="classes" delegateCommandSystemProperties="true">            <xmlfileset dir="${base.dir}" includes="${testng.file}"/>        </testng>    </target></project>

运行
前提:项目根目录下配置好了testng.xml
进入项目根目录,执行命令ant,即可

0 0