Ant的安装和使用

来源:互联网 发布:源码baiboku 编辑:程序博客网 时间:2024/05/21 10:06

1、ant是什么?

  是一个将软件编译、测试、部署等步骤联系在一起加以自动化的一个工具

2、下载安装

  http://blog.csdn.net/Lanyangyangb/article/details/73610280?locationNum=6&fps=1

3、在eclipce中的使用

准备工作:

  项目右键——new——folder——folder name: lib

  将testng-6.8.5.jar 、jcommander.jar 放入lib

  项目右键——new——file——build.xml  (文件名不能写错)

  放入代码

<?xml version="1.0"  encoding="UTF-8" ?><project name="HelloWorld" default="regression" basedir="."><property name="src" value="src"/><property name="dest" value="classes"/><property name="testng.dir"  value="${basedir}\lib"/><property name="testng.output.dir" value="${basedir}\test-output"/> <path id="class1">        <fileset dir="${basedir}\lib" includes="*jar"/>        <pathelement location="${dest}"/>        <pathelement location="${src}"/> </path><taskdef resource="testngtasks" classpath="${testng.dir}/testng-6.8.5.jar"/><target name="init">    <delete dir="${dest}"/>    <mkdir dir="${dest}"/></target><target name="compile" depends="init">   <javac srcdir="${src}" destdir="${dest}"  classpathref="class1" encoding="UTF8" includeantruntime="off" debug="on" debuglevel="lines,vars,source"/></target><target name="regression" depends="compile">        <echo>running testng</echo>        <testng outputdir="${testng.output.dir}" classpathref="class1" delegateCommandSystemProperties="true">            <xmlfileset dir="${basedir}" includes="testng.xml"/>        </testng></target></project>

4、运行build.xml

  可以右键Run As——Ant build

  也可以用cmd进入build.xml所在目录,使用ant命令

 

原创粉丝点击