Skip to content

Instantly share code, notes, and snippets.

@sahajamit
Created August 18, 2016 06:00
Show Gist options
  • Save sahajamit/2613c42ac93a0b4426a33eca57cd6069 to your computer and use it in GitHub Desktop.
Save sahajamit/2613c42ac93a0b4426a33eca57cd6069 to your computer and use it in GitHub Desktop.
Ant Build xml to run testng xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. -->
<project name="Automation" default="run" basedir=".">
<!-- ________________________initialize properties____________________________ -->
<property environment="env"/>
<property name="ws.home" value="."/>
<property name="ws.jars" value="${ws.home}/lib"/>
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="ng.result" value="test-output"/>
<target name="setClassPath" unless="${test.classpath}">
<path id="classpath_jars">
<pathelement location="${ws.jars}/log4j-1.2.17.jar"/>
<pathelement location="${ws.jars}/selenium-java-2.42.2.jar"/>
<pathelement location="${ws.jars}/selenium-server-standalone-2.42.2.jar"/>
<pathelement location="${ws.jars}/Appium/java-client-2.1.0.jar"/>
<pathelement location="${ws.jars}/csvjdbc-1.0-18.jar"/>
<pathelement location="${ws.jars}/sqljdbc4.jar"/>
<pathelement location="${ws.jars}/javax.mail.jar"/>
<pathelement location="${ws.jars}/pdfbox-app-1.8.6.jar"/>
<pathelement location="${ws.jars}/hamcrest-core-1.3.jar"/>
<pathelement location="${ws.jars}/hamcrest-library-1.3.jar"/>
<pathelement location="${ws.jars}/json-smart-1.2.jar"/>
<pathelement location="${ws.jars}/javax-xml-soap-1.6.0.jar"/>
<pathelement location="${ws.jars}/dom4j-1.6.1.jar"/>
<pathelement location="${ws.jars}/poi-3.10-FINAL-20140208.jar"/>
<pathelement location="${ws.jars}/poi-examples-3.10-FINAL-20140208.jar"/>
<pathelement location="${ws.jars}/poi-excelant-3.10-FINAL-20140208.jar"/>
<pathelement location="${ws.jars}/poi-ooxml-3.10-FINAL-20140208.jar"/>
<pathelement location="${ws.jars}/poi-ooxml-schemas-3.10-FINAL-20140208.jar"/>
<pathelement location="${ws.jars}/poi-scratchpad-3.10-FINAL-20140208.jar"/>
<pathelement location="${ws.jars}/stax-api-1.0.1.jar"/>
<pathelement location="${ws.jars}/xmlbeans-2.3.0.jar"/>
<pathelement location="${ws.jars}/joda-time-2.4.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/jackson-core-asl-1.7.1.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/jackson-mapper-asl-1.7.1.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/jetty-http-7.3.0.v20110203.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/jetty-util-7.3.0.v20110203.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/quality-check-1.3.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/slf4j-jdk14-1.5.3.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/uadetector-core-0.9.10.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/uadetector-resources-2013.10.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/slf4j-api-1.5.3.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/browsermob-proxy-2.0-beta-10-SNAPSHOT.jar"/>
<pathelement location="${ws.jars}/BrowsermobProxy/httpclient-4.3.4.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-client-1.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-client-meta-1.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-docs-3.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-docs-meta-3.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-spreadsheet-3.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-spreadsheet-meta-3.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-base-1.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-books-1.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-books-meta-1.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-codesearch-2.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-media-1.0.jar"/>
<pathelement location="${ws.jars}/GoogleApi/lib/gdata-core-1.0.jar"/>
<pathelement location="${ws.jars}/RestAssured/activation-1.1.jar"/>
<pathelement location="${ws.jars}/RestAssured/btf-1.2.jar"/>
<pathelement location="${ws.jars}/RestAssured/commons-codec-1.6.jar"/>
<pathelement location="${ws.jars}/RestAssured/commons-lang3-3.3.2.jar"/>
<pathelement location="${ws.jars}/RestAssured/commons-logging-1.1.3.jar"/>
<pathelement location="${ws.jars}/RestAssured/groovy-2.3.6.jar"/>
<pathelement location="${ws.jars}/RestAssured/groovy-json-2.3.6.jar"/>
<pathelement location="${ws.jars}/RestAssured/groovy-xml-2.3.6.jar"/>
<pathelement location="${ws.jars}/RestAssured/guava-16.0.1.jar"/>
<pathelement location="${ws.jars}/RestAssured/httpcore-4.3.2.jar"/>
<pathelement location="${ws.jars}/RestAssured/httpmime-4.3.5.jar"/>
<pathelement location="${ws.jars}/RestAssured/jackson-annotations-2.4.0.jar"/>
<pathelement location="${ws.jars}/RestAssured/jackson-core-2.4.2.jar"/>
<pathelement location="${ws.jars}/RestAssured/jackson-coreutils-1.8.jar"/>
<pathelement location="${ws.jars}/RestAssured/jackson-databind-2.4.2.jar"/>
<pathelement location="${ws.jars}/RestAssured/jopt-simple-4.6.jar"/>
<pathelement location="${ws.jars}/RestAssured/json-path-2.3.3.jar"/>
<pathelement location="${ws.jars}/RestAssured/json-schema-core-1.2.4.jar"/>
<pathelement location="${ws.jars}/RestAssured/json-schema-validator-2.2.5.jar"/>
<pathelement location="${ws.jars}/RestAssured/json-schema-validator-2.3.3.jar"/>
<pathelement location="${ws.jars}/RestAssured/jsr305-2.0.1.jar"/>
<pathelement location="${ws.jars}/RestAssured/libphonenumber-6.0.jar"/>
<pathelement location="${ws.jars}/RestAssured/mailapi-1.4.3.jar"/>
<pathelement location="${ws.jars}/RestAssured/msg-simple-1.1.jar"/>
<pathelement location="${ws.jars}/RestAssured/rest-assured-2.3.3.jar"/>
<pathelement location="${ws.jars}/RestAssured/rhino-1.7R4.jar"/>
<pathelement location="${ws.jars}/RestAssured/tagsoup-1.2.1.jar"/>
<pathelement location="${ws.jars}/RestAssured/uri-template-0.9.jar"/>
<pathelement location="${ws.jars}/Other_Utils/json-path-0.9.0.jar"/>
</path>
<pathconvert pathsep=";" property="test.classpath" refid="classpath_jars"/>
</target>
<!-- Prior to this, set the ANT location in the Environment variable. Eclipse by default has the ANT bundled.-->
<target name="init" depends="setClassPath">
<tstamp>
<format property="start.time" pattern="MM/dd/yyyy hh:mm aa" offset="-5" unit="hour"/>
</tstamp>
<condition property="ANT" value="${env.ANT_HOME}/bin/ant.bat" else="${env.ANT_HOME}/bin/ant">
<os family="windows"/>
</condition>
<taskdef name="testng" classpath="${test.classpath}" classname="org.testng.TestNGAntTask"/>
</target>
<!--clean-->
<target name="clean">
<echo message="Cleaning destination directory..."/>
<delete dir="${test.dest}"/>
</target>
<!--compile-->
<target name="compile" depends="init, clean"> <!-- INit removed-->
<delete includeemptydirs="true" quiet="true">
<fileset dir="${test.dest}" includes="**/*"/>
</delete>
<echo message="Making directory..."/>
<mkdir dir="${test.dest}"/>
<echo message="classpath...: ${test.classpath}"/>
<echo message="Compiling..."/>
<fileset dir="${ws.jars}" includes="${test.classpath}"/>
<echo message="Using Java version ${ant.java.version}."/>
<javac debug="true" destdir="${test.dest}" srcdir="${test.src}" includeantruntime="false">
<compilerarg value="-Xlint:deprecation"/>
<compilerarg value="-Xlint:unchecked"/>
<classpath path="${test.classpath}"/>
</javac>
</target>
<!--run-->
<target name="run" depends="compile">
<testng classpath="${test.classpath}: ${test.dest}" suitename="RegistrationValidation">
<xmlfileset dir="${ws.home}/testng_xmls" includes="testng.xml"/>
</testng>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment