Ant file for running a suite file
For running a suite file provide the ant script with the task "testng". The "testng" task will only be executed if a task definition for testng is specified.
<property name="xml" value=""/>
<taskdef name="testng" classname="com.beust.testng.TestNGAntTask" classpathref="classpath"/>
<target name="run_tests" depends="compile the code">
<echo message="running tests" />
<testng classpathref="classpath of jars and other classes used" haltOnfailure="true">
<xmlfileset file="${xml}" />
</testng>
</target>
A xml suite file can be used to specify the test to be run. The parameters to be passed to the test etc.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1" verbose="1" >
<test name="Regression1" preserve-order="true">
<parameter name="env" value="test"/>
<parameter name="driver" value="ie"/>
<classes>
<class name="mytests.First">
</class>
</classes>
</test>
</suite>
Save the above suite as Sample.xml. It contains the class to be executed, the parameters to be passed to the test etc.
Ant Command
ant -Dxml = Sample.xml
No comments:
Post a Comment