Build XML file for ANT

 Build XML file for ANT

<?xml version="1.0"?>
<project name="de.vogella.build.ant.first" default="makexsltreports" basedir=".">
<!-- Defining property -->
<property name="project.dir" value="${basedir}"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="jar.dir" value="D:\Automation_Testing\selenium-java-2.39.0\selenium-2.39.0\libs"/>
<property name="src.dir" value="${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="src/dummy/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>
</target>
</project>
======================================================================



Donate:

Please Donate the some money (anything do you want) for my
blog if you beneficial for this, I will provide more real example for the
latest technique for whom who wants to make a carrier in IT field or solved
some problem, My Name is – RITESH KUMAR SINGH A/C number- 913010044116345 AXIS
Bank LTD :- Vaishali NCR, India-001
 

Testng xml file

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Sample test Suite">
   <test name="Sample test">
       <classes>
                  <class name="SaveData" />
    </classes>
    </test>
</suite>

No comments:

Post a Comment