ANT Installation And Configuration :
Step -1 : First
of all, we will install the Java in the system from
Download Java and download jdk-7u60-windows-i586.exe for window 7.
Step -3 :
Unzip the downloaded file into C drive.
Step -4 : Set the environment for
windows7:
a) Right
click on My computer > properties >advanced System setting >
Environment Variables> In system variables and Click New>Enter
Variable name ANT_HOME and Enter variable value
“C:\apache-ant-1.9.4-bin\apache-ant-1.9.4”(Give the path of
apache-ant-1.9.4)
b)
Again In system variable, go to the path and click edit and add the
path of your apache-ant-1.9.4 bin folder “
C:\apache-ant-1.9.4-bin\apache-ant-1.9.4\bin”.
Step -6 :
Unzip it and copy the testng-results.xsl from testng-xslt1.1.2
folder(testng-xslt1.1.2\src\main\resources\testng-results.xsl). and paste into the project.
Step -8 :
Now Copy saxon-8.7 and SaxonLiaison library from
(testng-xlt1.1.2\lib\saxon-8.7.jar).and paste into the project Jar Folder.
Step -9 : Copy tool.jar file from java jdk and paste into ant library.
Step -10 : Modify
your build.xml -
<?xml
version="1.0"
encoding="UTF-8"
?>
<project
name="GetIt_Project"
default="sendMail"
basedir=".">
<description>
simple
example build file
</description>
<!--
set global properties for this build -->
<property
name="project.dir"
location="${basedir}"
/>
<property
name="jar.dir"
location="D:\workspace\GetIt_Project\Jars"
/>
<property
name="build.dir"
location="${basedir}/build"
/>
<property
name="src.dir"
location="${basedir}/src"
/>
<property
name="ng.result"
value="test-output"
/>
<!--
Setting Classpath for jar files -->
<target
name="setClassPath">
<path
id="classpath_jars">
<pathelement
path="${basedir}/"
/>
<fileset
dir="${jar.dir}">
<include
name="*.jar"
/>
</fileset>
</path>
<pathconvert
pathsep=":"
property="test.classpath"
refid="classpath_jars"
/>
</target>
<!--
Loading Testng -->
<target
name="loadTestNG"
depends="setClassPath">
<taskdef
resource="testngtasks"
classpath="${test.classpath}"
/>
</target>
<!--
Deleting directories -->
<target
name="clean">
<echo
message="deleting
existing build directory" />
<delete
dir="${build.dir}"
/>
</target>
<!--
Creating build folder to store compiled classes -->
<target
name="init"
depends="clean,setClassPath">
<mkdir
dir="${build.dir}"
/>
</target>
<!--
Compiling java files -->
<target
name="compile"
depends="clean,init,setClassPath,loadTestNG">
<echo
message=""
/>
<echo
message="compiling………."
/>
<javac
destdir="${build.dir}"
srcdir="${src.dir}"
includeantruntime="false"
classpath="${test.classpath}"
/>
</target>
<target
name="run"
depends="compile">
<testng
classpath="${test.classpath}:${build.dir}">
<xmlfileset
dir="${basedir}"
includes="testng.xml"
/>
</testng>
</target>
<!--
adding XSLT report target to produce XSLT report -->
<target
name="makexsltreports"
depends="run">
<delete
dir="${project.dir}/XSLT_Reports/output">
</delete>
<mkdir
dir="${project.dir}/XSLT_Reports/output"
/>
<xslt
in="${ng.result}/testng-results.xml"
style="${basedir}/testng-results.xsl"
out="${project.dir}/XSLT_Reports/output/index.html"
classpathref="classpath_jars"
processor="SaxonLiaison">
<param
name="testNgXslt.outputDir"
expression="${project.dir}/XSLT_Reports/output/"
/>
<param
name="testNgXslt.showRuntimeTotals"
expression="true"
/>
<param
expression="true"
name="testNgXslt.sortTestCaseLinks"
/>
<param
expression="FAIL,SKIP,PASS,CONF,BY_CLASS"
name="testNgXslt.testDetailsFilter"
/>
</xslt>
<!--
<echo message="This is a message" />-->
</target>
<!--
using javax.mail.jar and javax.activation.jar trying to send report
as zip file -->
<target
name="sendMail"
depends="makexsltreports">
<!--
Compressing all the output file of XSLT report -->
<zip
destfile="${project.dir}/XSLT_Reports/output.zip"
basedir="${project.dir}/XSLT_Reports/output"
/>
<mail
tolist="persia.scorpio@gmail.com"
from="persia.scorpio@gmail.com"
subject="Email
subject"
mailhost="smtp.gmail.com"
mailport="465"
ssl="true"
user="test@gmail.com"
password="8826181801">
<attachments>
<fileset
dir="${project.dir}/XSLT_Reports/">
<include
name="**/*.zip"/>
</fileset>
</attachments>
</mail>
</target>
</project>
How can we run build.xml:
open the command promt .
Go to the your project
location.( D:\workspace\GetIt_Project)
Type ant and press enter it is
automatically run the build.xml.