Note: Selenium and testng installation and use of many examples on the Internet, here is the main record of my ant environment in the building of some examples
One. Installation
1. Download ant release version to http://ant.apache.org/bindownload.cgi
2, the download of the zip file to any directory, such as D:\ant
3. Add Ant_home=d:\ant to environment variables (replace with your unpacked directory)
4, in the environment variable path to increase;D: \ant\bin;
5, open cmd, input ant, if prompted the information to prove successful
Buildfile:build.xml does not exist!
Build failed
Or
Installing Ant
Unzip the compressed package you downloaded and place it in any location you like: c:/ant/, and then in "My Computer-> Properties-> Advanced-> environment variable-> new" specify: Ant_home, Value: c:/ant, and add in Classpath: %ant_home%\bin;
Two. Description
1, after the installation is completed,
Open cmd, enter ant, and if prompted, the information proves successful.
Buildfile:build.xml does not exist!
Build failed
The failed here does not mean that your ant installation failed, but that you only enter the Ant command and look for a file called Build.xml in your current directory, and if you do not have this build.xml file in your current directory, you will report Build.xml does not exist!, and Build.xml store things you need to do, like build, execute, etc.
2, I under the project, that is, bin and SRC under the same directory to build a Lib folder, all need to use the jar bag all put inside, and then in the build.xml inside to quote,
Specific Build.xml documents: XML version= "1.0" encoding= "UTF-8"?>
< project name = "Selenium" default = "start_server_and_run_tests" Basedir = "." >
< property name = "src" value = "src"/>
< property name = "Dest" value = "Classes"/>
<!--<property name= "Lib.dir" value= "Lib"/>-->
< property name = "Lib.dir" value = "${basedir}/lib"/>
< property name = "Suite.dir" value = "${basedir}/test-output/suite"/>
< property name = "Selenium_jar" value = "Selenium.jar"/>
< 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}"/>
</Target >
< target name = "Compile" depends = "init" >
< Javac Srcdir = "${src}" Destdir = "${dest}" Classpathref = "Compile.path"/>
</Target >
<!--run testng ant task-->
< Taskdef resource = "Testngtasks" classpath = "${lib.dir}/testng.jar"/>
< target name = "Start_server_and_run_tests" depends = "compile" description = "Start Selenium server and Run tests" >
< parallel >
< Antcall target = "run_tests" >
</Antcall >
</Parallel >
</Target >
< target name = "Run_tests" depends = "compile" >
< testng Classpathref = "Compile.path" Failureproperty = "test.failed" >
<!--XML test suite file-->
< Xmlfileset dir = "${suite.dir}" >
< include name = "Test.xml"/>
</Xmlfileset >
</testng >
< Antcall target = "Sendreport"/>
< fail message = "ERROR:TEST failed!!!!!" if = "test.failed"/>
</Target >
< target name = "Sendreport" >
< Delete dir = "${dest}"/>
< Antcall target = "transform"/>
</Target >
< target name = "Transform" >
< XSLT in = "${basedir}/test-output/testng-results.xml" style = "${basedir}/test-output/testng-results.xsl" out = "${" basedir}/test-output/index1.html "classpathref =" Compile.path "processor =" Saxonliaison ">
<!--need to specify the directory again-->
< param name = "Testngxslt.outputdir" expression = "${basedir}/test-output/"/>
< param name = "testngxslt.showruntimetotals" expression = "true"/>
<!--<classpath refid= "Compile.path"/>-->
</XSLT >
</Target >
</Project > origin:http://www.cnblogs.com/zhangfei/archive/2011/04/07/2007579.html