Ant build file for TestNG:->
Sample Ant build.xml file to run TestNG
<?xml version="1.0" encoding="UTF-8"?>
<!--
Filename: build.xml
Note: You have to change the followings according to your environment:
-<pathelement location="lib/testng/testng-5.14.7.jar"/>
-<pathelement location="bin"/>
-->
<project basedir="." default="testng_nice_report" name="Sample of Ant file for TestNG">
<!-- Define <testng> task -->
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="C:/Selenuim_Automation/Jars and Properties File/jars/testng.jar" />
</classpath>
</taskdef>
<!-- Directory name where the TestNG report will be saved. -->
<property name="testng.output.dir" value="testng_output" />
<!-- Directory path of compiled classes(i.e *.class) -->
<path id="classes">
<pathelement location="C:/Selenuim_Automation/MyAnt/bin" />
<pathelement location="C:/Selenuim_Automation/Jars and Properties File/jars/selenium-server-standalone-2.32.0.jar"/>
<pathelement location="C:/Selenuim_Automation/Jars and Properties File/jars/log4j-1.2.14.jar"/>
</path>
<!--
Target to run TestNG. It will run according to what are defined in testng.xml.
The report will be saved at .../testng_output/index.html.
-->
<target name="runTestNG">
<mkdir dir="${testng.output.dir}" />
<!-- Create the output directory. -->
<testng outputdir="${testng.output.dir}" classpathref="classes">
<xmlfileset dir="." includes="testng.xml" />
</testng>
</target>
<!--
Example for TestNG-XSLT
Run this target only after TestNG had generated the xml resutl file(i.e. testng_output/testng-results.xml).
Change TestNG-XSLT stylesheet path accordingly(i.e. lib/testng-xslt-0.6.2/src/main/resources/testng-results.xsl).
-->
<target name="testng_nice_report" depends="runTestNG" >
<mkdir dir="testng_nice_report" />
<xslt in="testng_output/testng-results.xml" style="C:/Selenuim_Automation/MyAnt/src/com/xsl/testng-results.xsl" out="testng_nice_report/index.html">
<param name="testNgXslt.outputDir" expression="C:/Selenuim_Automation/MyAnt/testng_nice_report" />
<param name="testNgXslt.showRuntimeTotals" expression="true" />
</xslt>
</target>
</project>
Ant testng.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Filename: testng.xml
Note: You have to change the following according to your environment:
-<class name="com.packageName.MyTestClassName" />
-->
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="My Test Suite" >
<test name="My Test1" >
<!-- Add all classes you would like TestNG to run. -->
<classes>
<class name="com.LoginViaTestNG.LoginTestt" />
</classes>
</test>
</suite>
No comments:
Post a Comment