Getting Started with APACHE ANT

Getting Started with APACHE ANT

Apache ANT (Another Neat Tool) is a Java based build tool and uses the XML file format to write build files.

Need for a Build Tool

On an average, a developer spends a substantial amount of time doing everyday tasks, including the following:

To automate and simplify the above tasks, Apache ANT is useful. Moreover, the tool can be executed directly from the command line.

History of Apache ANT

James Duncan Davidson, the original author of Tomcat, created ANT. It was originally bundled as a part of Tomcat distribution. In order to overcome the various challenges associated with the Apache Make tool, Apache ANT was developed. In the year 2000, it was promoted as an independent project in Apache. Ever since then, various versions of Apache Ant have been released, 1.9.6 being the latest.

Benefits of Using ANT

Benefits of Using ANT

Installing ANT in your system and getting ready to work with it

getting ready to work with it

Prerequisites

http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Once the download is complete, install the executable file into your system. Then, set Java home as Environmental variable in your system, as shown below.

set Java home as Environmental variable in your system

  1. Right-click on the My Computer icon from your desktop.
  2. Click on Properties.
  3. Click on Advanced system settings.
  4. Click the Environment Variables button.
  5. You will see the Environment Variables interface.
  6. Click New associated with the System variable section.
  7. You will see the New System Variable interface.
  8. Put JAVA_HOME into the variable name field.
  9. Click OK.
  10. Click OK.

You can check whether Java has been successfully installed by running the following command into the command prompt: java –version.

command prompt: java –version

Once you execute the above command, you will see the following screen:

image013

After downloading the file, unzip the file into C:\Program files and put the same folder into the C:\Program Files\JAVA folder as well.

unzip the file into C:\Program files and put the same folder into the C:\Program Files\JAVA folder as well.

Set ANT home as Environmental variable in your system, as shown below.

image017

User can see the above screen if he follows the following steps:

  1. Right-click on the My Computer icon from your desktop
  2. Click on Properties
  3. Click on Advanced system settings
  4. Click the Environment Variables button
  5. You will see the Environment Variables interface
  6. Click New associated with the System variable section
  7. You will see the New System Variable interface
  8. Put ANT_HOME into the variable name field
  9. Click OK
  10. Click OK
  11. Go to System Variables>Path, select the row and click Edit. Define two paths (C:\Program Files\apache-ant-1.9.3\bin, C:\Program Files\java\apache-ant-1.9.3\bin) as shown below.
  12. Click OK

image019

Note: Place the tools.jar file into your JRE\lib folder (In the above case, path of lib folder is “C:\Program Files\Java\jre1.5.0_11\lib”)

You can check whether ANT is successfully installed by running the following command into the command prompt: ant –version

You can check whether ANT is successfully installed by running the following command into the command prompt: ant –version

Once you execute the above command, you will see the following screen:

Once you execute the above command, you will see the following screen:

  1. Download the Selenium 2.5.0 from https://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.5.0.jar&can=4&q=selenium-server link and put “selenium-server-standalone-2.5.0.jar” file in your project lib
  2. Download TestNG file from http://mirrors.ibiblio.org/pub/mirrors/maven/org.testng/jars/testng-5.5.jar and keep the same file into lib
  3. Download Google Chrome Driver from http://code.google.com/p/selenium/wiki/ChromeDriver
  4. Download IE Driver under the Internet Explorer Driver Server http://docs.seleniumhq.org/download/
  5. Download dom4j*.jar from http://grepcode.com/snapshot/repo1.maven.org/maven2/dom4j/dom4j/1.6.1 and keep the same file into lib
  6. Download jaxen*.jar file from http://jaxen.codehaus.org/releases.html and keep the same file into lib

Note: All required jar files and drivers are placed in lib folder.

lib folder

Test Setup:

Put the complete code base into the machine.

Test Execution:

run the following command on the command prompt: ant runall

image029

Reporting: 

After executing different tests, you can see the execution result in the “\test-output” folder. You need to go into the different tests folder and open the index.html file to see the results.

SHARE THIS

Get A Free Quote