Selenium+java+testng+ant Environment Construction

Source: Internet
Author: User

One. Installation

1. Download the ant release version to http://ant.apache.org/bindownload.cgi

2. Unzip the downloaded zip file to any directory, such as D:\ant

3. Add ant_home=d:\ant to the environment variable (replace with the directory you unzipped)

4, add;D in the environment variable path: \ant\bin;

5, open cmd, enter ant, if prompted to prove the success of the information

Buildfile:build.xml does not exist!

Build failed

Or

Installing Ant

Unzip the compressed package you downloaded, and then place it anywhere you like, such as c:/ant/, and then specify: Ant_home, the value is: c:/ant, and add it in the classpath: %ant_home%\bin;

Two. Description

1, after the installation is complete,

Open cmd, enter ant, and if you are 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 because you only enter the Ant command, will be in your current directory to find a file called Build.xml, if you do not have this build.xml file in the current directory, will be reported Build.xml does not exist!, and Build.xml is what you need to do, like build, execute, etc

2, I am under the project, that is, the bin and src in the same directory built a Lib folder, put all the necessary jar package into the inside, and then in the build.xml inside to quote,

Specific Build.xml files:

<?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 here again--
<param name= "Testngxslt.outputdir" expression= "${basedir}/test-output/"/>
<param name= "Testngxslt.showruntimetotals" expression= "true"/>
<!--<classpath refid= "Compile.path"/>-->
</xslt>
</target>
</project>

Selenium+java+testng+ant Environment Construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.