1*83a54b2fSSadaf Ebrahimi<html> 2*83a54b2fSSadaf Ebrahimi <head> 3*83a54b2fSSadaf Ebrahimi <title>TestNG - Ant</title> 4*83a54b2fSSadaf Ebrahimi 5*83a54b2fSSadaf Ebrahimi <link rel="stylesheet" href="testng.css" type="text/css" /> 6*83a54b2fSSadaf Ebrahimi <link type="text/css" rel="stylesheet" href="http://beust.com/beust.css" /> 7*83a54b2fSSadaf Ebrahimi <script type="text/javascript" src="http://beust.com/prettify.js"></script> 8*83a54b2fSSadaf Ebrahimi <script type="text/javascript" src="banner.js"></script> 9*83a54b2fSSadaf Ebrahimi 10*83a54b2fSSadaf Ebrahimi <script type="text/javascript" src="http://beust.com/scripts/shCore.js"></script> 11*83a54b2fSSadaf Ebrahimi <script type="text/javascript" src="http://beust.com/scripts/shBrushJava.js"></script> 12*83a54b2fSSadaf Ebrahimi <script type="text/javascript" src="http://beust.com/scripts/shBrushXml.js"></script> 13*83a54b2fSSadaf Ebrahimi <script type="text/javascript" src="http://beust.com/scripts/shBrushBash.js"></script> 14*83a54b2fSSadaf Ebrahimi <script type="text/javascript" src="http://beust.com/scripts/shBrushPlain.js"></script> 15*83a54b2fSSadaf Ebrahimi <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shCore.css"/> 16*83a54b2fSSadaf Ebrahimi <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shThemeCedric.css"/> 17*83a54b2fSSadaf Ebrahimi <script type="text/javascript"> 18*83a54b2fSSadaf Ebrahimi SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf'; 19*83a54b2fSSadaf Ebrahimi SyntaxHighlighter.defaults['gutter'] = false; 20*83a54b2fSSadaf Ebrahimi SyntaxHighlighter.all(); 21*83a54b2fSSadaf Ebrahimi </script> 22*83a54b2fSSadaf Ebrahimi 23*83a54b2fSSadaf Ebrahimi</head> 24*83a54b2fSSadaf Ebrahimi 25*83a54b2fSSadaf Ebrahimi<body onLoad="prettyPrint()"> 26*83a54b2fSSadaf Ebrahimi 27*83a54b2fSSadaf Ebrahimi<script type="text/javascript"> 28*83a54b2fSSadaf Ebrahimi displayMenu("ant.html") 29*83a54b2fSSadaf Ebrahimi</script> 30*83a54b2fSSadaf Ebrahimi 31*83a54b2fSSadaf Ebrahimi<h2 align="center">TestNG Ant Task</h2> 32*83a54b2fSSadaf Ebrahimi<p>You define the TestNG ant task as follows:</p> 33*83a54b2fSSadaf Ebrahimi 34*83a54b2fSSadaf Ebrahimi<pre class="brush: xml"> 35*83a54b2fSSadaf Ebrahimi<taskdef resource="testngtasks" classpath="testng.jar"/> 36*83a54b2fSSadaf Ebrahimi</pre> 37*83a54b2fSSadaf Ebrahimi 38*83a54b2fSSadaf EbrahimiThis task runs TestNG tests and is always run in a forked JVM. It 39*83a54b2fSSadaf Ebrahimiaccepts the following attributes: <br> 40*83a54b2fSSadaf Ebrahimi <table border="2" id="table1"> 41*83a54b2fSSadaf Ebrahimi <tr> 42*83a54b2fSSadaf Ebrahimi <th>Attribute </th> 43*83a54b2fSSadaf Ebrahimi <th>Description </th> 44*83a54b2fSSadaf Ebrahimi <th>Required </th> 45*83a54b2fSSadaf Ebrahimi </tr> 46*83a54b2fSSadaf Ebrahimi <tr> 47*83a54b2fSSadaf Ebrahimi <td><tt>classfilesetref</tt> </td> 48*83a54b2fSSadaf Ebrahimi <td>A reference to a 49*83a54b2fSSadaf Ebrahimi <a href="http://ant.apache.org/manual/Types/resources.html#collection">ResourceCollection</a> 50*83a54b2fSSadaf Ebrahimi containing the test classes to be run. Only File based 51*83a54b2fSSadaf Ebrahimi <a href="http://ant.apache.org/manual/Types/resources.html#collection">ResourceCollection</a>s 52*83a54b2fSSadaf Ebrahimi are supported (ie. <a href="http://ant.apache.org/manual/Types/fileset.html">FileSet</a>).</td> 53*83a54b2fSSadaf Ebrahimi <td> </td> 54*83a54b2fSSadaf Ebrahimi </tr> 55*83a54b2fSSadaf Ebrahimi <tr> 56*83a54b2fSSadaf Ebrahimi <td><tt>classpath</tt> </td> 57*83a54b2fSSadaf Ebrahimi <td>A PATH-like structure for the tests to be run. </td> 58*83a54b2fSSadaf Ebrahimi <td> </td> 59*83a54b2fSSadaf Ebrahimi </tr> 60*83a54b2fSSadaf Ebrahimi <tr> 61*83a54b2fSSadaf Ebrahimi <td><tt>classpathref</tt> </td> 62*83a54b2fSSadaf Ebrahimi <td>A reference to a PATH-like structure for the tests to be run. </td> 63*83a54b2fSSadaf Ebrahimi <td> </td> 64*83a54b2fSSadaf Ebrahimi </tr> 65*83a54b2fSSadaf Ebrahimi <tr> 66*83a54b2fSSadaf Ebrahimi <td><tt>configFailurePolicy</tt> </td> 67*83a54b2fSSadaf Ebrahimi <td>Whether TestNG should <tt>continue</tt> to execute the remaining tests in the suite or <tt>skip</tt> them if an @Before* method fails.</td> 68*83a54b2fSSadaf Ebrahimi <td>No. Defaults to <tt>skip</tt></td> 69*83a54b2fSSadaf Ebrahimi </tr> 70*83a54b2fSSadaf Ebrahimi <tr> 71*83a54b2fSSadaf Ebrahimi <td><tt>dataProviderThreadCount</tt> </td> 72*83a54b2fSSadaf Ebrahimi <td>The number of threads to use for data providers 73*83a54b2fSSadaf Ebrahimi for this run. Ignored unless the parallel mode is also specified</td> 74*83a54b2fSSadaf Ebrahimi <td>1</td> 75*83a54b2fSSadaf Ebrahimi </tr> 76*83a54b2fSSadaf Ebrahimi <tr> 77*83a54b2fSSadaf Ebrahimi <td><tt>delegateCommandSystemProperties</tt> </td> 78*83a54b2fSSadaf Ebrahimi <td>Pass the command line properties as system properties.</td> 79*83a54b2fSSadaf Ebrahimi <td>No. Defaults to false </td> 80*83a54b2fSSadaf Ebrahimi </tr> 81*83a54b2fSSadaf Ebrahimi <tr> 82*83a54b2fSSadaf Ebrahimi <td><tt>dumpCommand</tt> </td> 83*83a54b2fSSadaf Ebrahimi <td>Print the TestNG launcher command. </td> 84*83a54b2fSSadaf Ebrahimi <td>No. Defaults to false </td> 85*83a54b2fSSadaf Ebrahimi </tr> 86*83a54b2fSSadaf Ebrahimi <tr> 87*83a54b2fSSadaf Ebrahimi <td><tt>failureProperty</tt> </td> 88*83a54b2fSSadaf Ebrahimi <td>The name of a property to set in the event of a failure. It is used 89*83a54b2fSSadaf Ebrahimi only if the <tt>haltonfailure</tt> is not set. </td> 90*83a54b2fSSadaf Ebrahimi <td>No.</td> 91*83a54b2fSSadaf Ebrahimi </tr> 92*83a54b2fSSadaf Ebrahimi <tr> 93*83a54b2fSSadaf Ebrahimi <td><tt>haltonfailure</tt> </td> 94*83a54b2fSSadaf Ebrahimi <td>Stop the build process if a failure has occurred during the test 95*83a54b2fSSadaf Ebrahimi run. </td> 96*83a54b2fSSadaf Ebrahimi <td>No. Defaults to false 97*83a54b2fSSadaf Ebrahimi </td> 98*83a54b2fSSadaf Ebrahimi <td> </td> 99*83a54b2fSSadaf Ebrahimi </tr> 100*83a54b2fSSadaf Ebrahimi <tr> 101*83a54b2fSSadaf Ebrahimi <td><tt>haltonskipped</tt> </td> 102*83a54b2fSSadaf Ebrahimi <td>Stop the build process if there is at least on skipped test. </td> 103*83a54b2fSSadaf Ebrahimi <td>No. Default to false </td> 104*83a54b2fSSadaf Ebrahimi </tr> 105*83a54b2fSSadaf Ebrahimi <tr> 106*83a54b2fSSadaf Ebrahimi <td><tt>groups</tt></td> 107*83a54b2fSSadaf Ebrahimi <td> 108*83a54b2fSSadaf Ebrahimi The list of groups to run, separated by spaces or commas.</td> 109*83a54b2fSSadaf Ebrahimi <td> 110*83a54b2fSSadaf Ebrahimi </td> 111*83a54b2fSSadaf Ebrahimi </tr> 112*83a54b2fSSadaf Ebrahimi <tr> 113*83a54b2fSSadaf Ebrahimi <td><tt>excludedgroups</tt></td> 114*83a54b2fSSadaf Ebrahimi <td> 115*83a54b2fSSadaf Ebrahimi The list of groups to exclude, separated by spaces or commas</td> 116*83a54b2fSSadaf Ebrahimi <td> 117*83a54b2fSSadaf Ebrahimi </td> 118*83a54b2fSSadaf Ebrahimi </tr> 119*83a54b2fSSadaf Ebrahimi <tr> 120*83a54b2fSSadaf Ebrahimi <td><tt>jvm</tt></td> 121*83a54b2fSSadaf Ebrahimi <td>The JVM to use, which will be run by <tt>Runtime.exec()</tt></td> 122*83a54b2fSSadaf Ebrahimi <td><tt>java</tt></td> 123*83a54b2fSSadaf Ebrahimi </tr> 124*83a54b2fSSadaf Ebrahimi <tr> 125*83a54b2fSSadaf Ebrahimi <td><tt>listeners</tt></td> 126*83a54b2fSSadaf Ebrahimi <td>A comma or space-separated list of fully qualified classes that are TestNG listeners (for example<tt> 127*83a54b2fSSadaf Ebrahimi <a href="http://testng.org/javadocs/org/testng/ITestListener.html"> 128*83a54b2fSSadaf Ebrahimi org.testng.ITestListener</a></tt> or <tt> 129*83a54b2fSSadaf Ebrahimi <a href="http://testng.org/javadocs/org/testng/IReporter.html"> 130*83a54b2fSSadaf Ebrahimi org.testng.IReporter</a>)</tt></td> 131*83a54b2fSSadaf Ebrahimi <td>No.</td> 132*83a54b2fSSadaf Ebrahimi </tr> 133*83a54b2fSSadaf Ebrahimi 134*83a54b2fSSadaf Ebrahimi <tr> 135*83a54b2fSSadaf Ebrahimi <td><tt>methods</tt></td> 136*83a54b2fSSadaf Ebrahimi <td>A comma separated list of fully qualified class name and method. For example <tt>com.example.Foo.f1,com.example.Bar.f2</tt>.</td> 137*83a54b2fSSadaf Ebrahimi <td>No.</td> 138*83a54b2fSSadaf Ebrahimi </tr> 139*83a54b2fSSadaf Ebrahimi 140*83a54b2fSSadaf Ebrahimi <tr> 141*83a54b2fSSadaf Ebrahimi <td><tt>mode</tt></td> 142*83a54b2fSSadaf Ebrahimi <td>Either <tt>"testng"</tt>, <tt>"junit"</tt> or <tt>"mixed"</tt>. Whether TestNG should run only TestNG tests, JUnit tests or both.</td> 143*83a54b2fSSadaf Ebrahimi <td>No. Defaults to "testng".</td> 144*83a54b2fSSadaf Ebrahimi </tr> 145*83a54b2fSSadaf Ebrahimi 146*83a54b2fSSadaf Ebrahimi <tr> 147*83a54b2fSSadaf Ebrahimi <td><tt>outputdir</tt> </td> 148*83a54b2fSSadaf Ebrahimi <td>Directory for reports output. 149*83a54b2fSSadaf Ebrahimi </td> 150*83a54b2fSSadaf Ebrahimi <td>No. Defaults to <tt>test-output</tt>. </td> 151*83a54b2fSSadaf Ebrahimi </tr> 152*83a54b2fSSadaf Ebrahimi <tr> 153*83a54b2fSSadaf Ebrahimi <td><tt>skippedProperty</tt> </td> 154*83a54b2fSSadaf Ebrahimi <td>The name of a property to set in the event of a skipped test. It is 155*83a54b2fSSadaf Ebrahimi used only if the <tt>haltonskipped</tt> is not set. </td> 156*83a54b2fSSadaf Ebrahimi <td>No. </td> 157*83a54b2fSSadaf Ebrahimi </tr> 158*83a54b2fSSadaf Ebrahimi <tr> 159*83a54b2fSSadaf Ebrahimi <td><tt>suiteRunnerClass</tt> </td> 160*83a54b2fSSadaf Ebrahimi <td>A fully qualified name of a TestNG starter. </td> 161*83a54b2fSSadaf Ebrahimi <td> 162*83a54b2fSSadaf Ebrahimi <p align="left">No. Defaults to <tt> 163*83a54b2fSSadaf Ebrahimi <a href="http://testng.org/javadocs/org/testng/TestNG.html">org.testng.TestNG</a> </tt></td> 164*83a54b2fSSadaf Ebrahimi </tr> 165*83a54b2fSSadaf Ebrahimi 166*83a54b2fSSadaf Ebrahimi <tr> 167*83a54b2fSSadaf Ebrahimi <td><tt>suiteThreadPoolSize</tt> </td> 168*83a54b2fSSadaf Ebrahimi <td>The size of a thread pool to run suites.</td> 169*83a54b2fSSadaf Ebrahimi <td> 170*83a54b2fSSadaf Ebrahimi <p align="left">No. Defaults to 1.</td> 171*83a54b2fSSadaf Ebrahimi </tr> 172*83a54b2fSSadaf Ebrahimi 173*83a54b2fSSadaf Ebrahimi <tr> 174*83a54b2fSSadaf Ebrahimi <td><tt>parallel</tt> </td> 175*83a54b2fSSadaf Ebrahimi <td>The parallel mode to use for running the tests - either methods or tests</td> 176*83a54b2fSSadaf Ebrahimi <td>No - if not present, parallel mode will not be selected</td> 177*83a54b2fSSadaf Ebrahimi </tr> 178*83a54b2fSSadaf Ebrahimi 179*83a54b2fSSadaf Ebrahimi <tr> 180*83a54b2fSSadaf Ebrahimi <td><tt>suitename</tt> </td> 181*83a54b2fSSadaf Ebrahimi <td>Sets the default name of the test suite, if one is not specified in a suite xml file or in the source code</td> 182*83a54b2fSSadaf Ebrahimi <td>No. Defaults to "Ant suite"</td> 183*83a54b2fSSadaf Ebrahimi </tr> 184*83a54b2fSSadaf Ebrahimi 185*83a54b2fSSadaf Ebrahimi <tr> 186*83a54b2fSSadaf Ebrahimi <td><tt>testJar</tt> </td> 187*83a54b2fSSadaf Ebrahimi <td>Path to a jar containing tests and a suite definition. </td> 188*83a54b2fSSadaf Ebrahimi <td> </td> 189*83a54b2fSSadaf Ebrahimi </tr> 190*83a54b2fSSadaf Ebrahimi 191*83a54b2fSSadaf Ebrahimi <tr> 192*83a54b2fSSadaf Ebrahimi <td><tt>testname</tt> </td> 193*83a54b2fSSadaf Ebrahimi <td>Sets the default name of the test, if one is not specified in a suite xml file or in the source code</td> 194*83a54b2fSSadaf Ebrahimi <td>No. defaults to "Ant test"</td> 195*83a54b2fSSadaf Ebrahimi </tr> 196*83a54b2fSSadaf Ebrahimi 197*83a54b2fSSadaf Ebrahimi <tr> 198*83a54b2fSSadaf Ebrahimi <td><tt>testnames</tt> </td> 199*83a54b2fSSadaf Ebrahimi <td>A comma separated list of test names, as defined 200*83a54b2fSSadaf Ebrahimi in the <test> tag. Only these tests will be run.</td> 201*83a54b2fSSadaf Ebrahimi <td>No. defaults to "Ant test"</td> 202*83a54b2fSSadaf Ebrahimi </tr> 203*83a54b2fSSadaf Ebrahimi 204*83a54b2fSSadaf Ebrahimi <tr> 205*83a54b2fSSadaf Ebrahimi <td><tt>threadCount</tt> </td> 206*83a54b2fSSadaf Ebrahimi <td>The number of threads to use for this run. Ignored unless the parallel mode is also specified</td> 207*83a54b2fSSadaf Ebrahimi <td>1</td> 208*83a54b2fSSadaf Ebrahimi </tr> 209*83a54b2fSSadaf Ebrahimi 210*83a54b2fSSadaf Ebrahimi <tr> 211*83a54b2fSSadaf Ebrahimi <td><tt>timeOut</tt></td> 212*83a54b2fSSadaf Ebrahimi <td>The maximum time out in milliseconds that all the tests should run 213*83a54b2fSSadaf Ebrahimi under.</td> 214*83a54b2fSSadaf Ebrahimi <td> </td> 215*83a54b2fSSadaf Ebrahimi </tr> 216*83a54b2fSSadaf Ebrahimi 217*83a54b2fSSadaf Ebrahimi <tr> 218*83a54b2fSSadaf Ebrahimi <td><tt>useDefaultListeners</tt></td> 219*83a54b2fSSadaf Ebrahimi <td>Whether the default listeners and reporters should be used.</td> 220*83a54b2fSSadaf Ebrahimi <td>Defaults to true.</td> 221*83a54b2fSSadaf Ebrahimi </tr> 222*83a54b2fSSadaf Ebrahimi <tr> 223*83a54b2fSSadaf Ebrahimi <td><tt>workingDir</tt></td> 224*83a54b2fSSadaf Ebrahimi <td>The directory where the ant task should change to before running 225*83a54b2fSSadaf Ebrahimi TestNG.</td> 226*83a54b2fSSadaf Ebrahimi <td> </td> 227*83a54b2fSSadaf Ebrahimi </tr> 228*83a54b2fSSadaf Ebrahimi <tr> 229*83a54b2fSSadaf Ebrahimi <td><tt>xmlfilesetref</tt> </td> 230*83a54b2fSSadaf Ebrahimi <td>A reference to a 231*83a54b2fSSadaf Ebrahimi <a href="http://ant.apache.org/manual/Types/resources.html#collection">ResourceCollection</a> 232*83a54b2fSSadaf Ebrahimi containing the suite definitions to be run. Only File based 233*83a54b2fSSadaf Ebrahimi <a href="http://ant.apache.org/manual/Types/resources.html#collection">ResourceCollection</a>s 234*83a54b2fSSadaf Ebrahimi are supported (ie. <a href="http://ant.apache.org/manual/Types/fileset.html">FileSet</a>).</td> 235*83a54b2fSSadaf Ebrahimi <td> </td> 236*83a54b2fSSadaf Ebrahimi </tr> 237*83a54b2fSSadaf Ebrahimi 238*83a54b2fSSadaf Ebrahimi <tr> 239*83a54b2fSSadaf Ebrahimi <td><tt>xmlPathInJar</tt></td> 240*83a54b2fSSadaf Ebrahimi <td>The path of the XML file inside the jar file, only applicable if <tt>testJar</tt> was specified</td> 241*83a54b2fSSadaf Ebrahimi <td>testng.xml</td> 242*83a54b2fSSadaf Ebrahimi </tr> 243*83a54b2fSSadaf Ebrahimi</table> 244*83a54b2fSSadaf Ebrahimi<br> 245*83a54b2fSSadaf EbrahimiOne of attributes <tt>classpath</tt>, <tt>classpathref</tt> or nested <tt> 246*83a54b2fSSadaf Ebrahimi<classpath></tt> must be used for providing the tests classpath. 247*83a54b2fSSadaf Ebrahimi<p>One of the attributes <tt>xmlfilesetref</tt>, <tt>classfilesetref</tt> or 248*83a54b2fSSadaf Ebrahiminested <tt><xmlfileset></tt>, respectively <tt><classfileset></tt> must be used 249*83a54b2fSSadaf Ebrahimifor providing the tests. </p> 250*83a54b2fSSadaf Ebrahimi 251*83a54b2fSSadaf Ebrahimi<h3>TestNG modes</h3> 252*83a54b2fSSadaf Ebrahimi<p>The TestNG mode gets applied when tests are passed to TestNG using <tt>classfilesetref</tt>, <tt>methods</tt> 253*83a54b2fSSadaf Ebrahimior nested <tt><classfileset></tt> and tells TestNG what kind of 254*83a54b2fSSadaf Ebrahimitests it should look for and run: 255*83a54b2fSSadaf Ebrahimi 256*83a54b2fSSadaf Ebrahimi<ul> 257*83a54b2fSSadaf Ebrahimi <li><tt>"testng"</tt>: find and run TestNG tests. 258*83a54b2fSSadaf Ebrahimi <li><tt>"junit"</tt>: find and run JUnit tests. 259*83a54b2fSSadaf Ebrahimi <li><tt>"mixed"</tt>: run both TestNG and JUnit tests. 260*83a54b2fSSadaf Ebrahimi</ul> 261*83a54b2fSSadaf Ebrahimi 262*83a54b2fSSadaf Ebrahimi<p><em>Note</em>: <tt>"junit"</tt> and <tt>"mixed"</tt> modes require the JUnit jar file on the classpath.</p> 263*83a54b2fSSadaf Ebrahimi 264*83a54b2fSSadaf Ebrahimi<h3><a name="nested">Nested Elements</a></h3> 265*83a54b2fSSadaf Ebrahimi<h4>classpath</h4> 266*83a54b2fSSadaf Ebrahimi<p>The <tt><testng></tt> task supports a nested <tt><classpath></tt> element 267*83a54b2fSSadaf Ebrahimithat represents a <em>PATH</em>-like structure. </p> 268*83a54b2fSSadaf Ebrahimi<h4>bootclasspath</h4> 269*83a54b2fSSadaf Ebrahimi<p>The location of bootstrap class files can be specified using this <em> 270*83a54b2fSSadaf EbrahimiPATH-like</em> structure - will be ignored if <tt>fork </tt>is not set. </p> 271*83a54b2fSSadaf Ebrahimi<h4>xmlfileset</h4> 272*83a54b2fSSadaf Ebrahimi<p>The suite definitions (<tt>testng.xml</tt>) can be passed to the task with a 273*83a54b2fSSadaf Ebrahimi<tt><a href="http://ant.apache.org/manual/Types/fileset.html">FileSet</a></tt> 274*83a54b2fSSadaf Ebrahimistructure. </p> 275*83a54b2fSSadaf Ebrahimi<h4>classfileset</h4> 276*83a54b2fSSadaf Ebrahimi<p>TestNG can also run directly on classes, also supplied with a <tt> 277*83a54b2fSSadaf Ebrahimi<a href="http://ant.apache.org/manual/Types/fileset.html">FileSet</a></tt> 278*83a54b2fSSadaf Ebrahimistructure.</p> 279*83a54b2fSSadaf Ebrahimi<h4>jvmarg</h4> 280*83a54b2fSSadaf Ebrahimi<p>Additional parameters may be passed to the new VM via nested <tt><jvmarg></tt> 281*83a54b2fSSadaf Ebrahimielements. For example: </p> 282*83a54b2fSSadaf Ebrahimi 283*83a54b2fSSadaf Ebrahimi<pre class="brush: xml"> 284*83a54b2fSSadaf Ebrahimi<testng> 285*83a54b2fSSadaf Ebrahimi <jvmarg value="-Djava.compiler=NONE" /> 286*83a54b2fSSadaf Ebrahimi <!-- ... --> 287*83a54b2fSSadaf Ebrahimi</testng> 288*83a54b2fSSadaf Ebrahimi</pre> 289*83a54b2fSSadaf Ebrahimi 290*83a54b2fSSadaf Ebrahimi<h4>sysproperty</h4> 291*83a54b2fSSadaf Ebrahimi<p>Use nested <tt><sysproperty></tt> elements to specify system properties 292*83a54b2fSSadaf Ebrahimirequired by the class. These properties will be made available to the virtual 293*83a54b2fSSadaf Ebrahimimachine during the execution of the test. The attributes for this element are 294*83a54b2fSSadaf Ebrahimithe same as for <em>environment variables</em>:</p> 295*83a54b2fSSadaf Ebrahimi 296*83a54b2fSSadaf Ebrahimi<pre class="brush: xml"> 297*83a54b2fSSadaf Ebrahimi<testng> 298*83a54b2fSSadaf Ebrahimi <sysproperty key="basedir" value="${basedir}"/> 299*83a54b2fSSadaf Ebrahimi <!-- ... --> 300*83a54b2fSSadaf Ebrahimi</testng> 301*83a54b2fSSadaf Ebrahimi</pre> 302*83a54b2fSSadaf Ebrahimi 303*83a54b2fSSadaf Ebrahimi<p>will run the test and make the <code>basedir</code> property 304*83a54b2fSSadaf Ebrahimiavailable to the test.</p> 305*83a54b2fSSadaf Ebrahimi 306*83a54b2fSSadaf Ebrahimi<h4>propertyset</h4> 307*83a54b2fSSadaf Ebrahimi<p>You may also use a nested <tt><propertyset></tt> element to specify a set of system properties that are defined 308*83a54b2fSSadaf Ebrahimioutside of the TestNG ant task. This allows for more flexible definitions of system properties, for instance selecting 309*83a54b2fSSadaf Ebrahimiall properties with a specific prefix or matching a regex. See the 310*83a54b2fSSadaf Ebrahimi<a href="http://ant.apache.org/manual/Types/propertyset.html">PropertySet page</a> in the 311*83a54b2fSSadaf Ebrahimi<a href="http://ant.apache.org/manual/">Ant manual</a> for full details. Here's a simple example:</p> 312*83a54b2fSSadaf Ebrahimi<pre class="brush: xml"> 313*83a54b2fSSadaf Ebrahimi <property name="myprop1" value="value 1"/> 314*83a54b2fSSadaf Ebrahimi <property name="myprop2" value="value 2"/> 315*83a54b2fSSadaf Ebrahimi 316*83a54b2fSSadaf Ebrahimi <propertyset id="propset1"> 317*83a54b2fSSadaf Ebrahimi <propertyref name="myprop1"/> 318*83a54b2fSSadaf Ebrahimi <propertyref name="myprop2"/> 319*83a54b2fSSadaf Ebrahimi </propertyset> 320*83a54b2fSSadaf Ebrahimi 321*83a54b2fSSadaf Ebrahimi <testng outputdir="${testng.report.dir}" classpathref="run.cp"> 322*83a54b2fSSadaf Ebrahimi <xmlfileset dir="${test15.dir}" includes="testng-single3.xml"/> 323*83a54b2fSSadaf Ebrahimi <propertyset refid="propset1"/> 324*83a54b2fSSadaf Ebrahimi </testng> 325*83a54b2fSSadaf Ebrahimi</pre> 326*83a54b2fSSadaf Ebrahimi<p>In this case, the system properties named "myprop1" and "myprop2" are passed along to the TestNG process.</p> 327*83a54b2fSSadaf Ebrahimi 328*83a54b2fSSadaf Ebrahimi<h4>reporter</h4> 329*83a54b2fSSadaf Ebrahimi<p>An inner <tt><reporter></tt> element is an alternative way to inject a 330*83a54b2fSSadaf Ebrahimicustom report listener allowing the user to set custom properties in order to fine-tune 331*83a54b2fSSadaf Ebrahimithe behavior of the reporter at run-time. 332*83a54b2fSSadaf Ebrahimi<br> 333*83a54b2fSSadaf EbrahimiThe element has one <tt>classname</tt> attribute which is mandatory, indicating 334*83a54b2fSSadaf Ebrahimithe class of the custom listener. In order to set the properties of the reporter, the 335*83a54b2fSSadaf Ebrahimi<tt><reporter></tt> element can contain several nested <tt><property></tt> 336*83a54b2fSSadaf Ebrahimielements which will provide the <tt>name</tt> and <tt>value</tt> attributes as seen below: 337*83a54b2fSSadaf Ebrahimi</p> 338*83a54b2fSSadaf Ebrahimi<pre class="brush: xml"> 339*83a54b2fSSadaf Ebrahimi<testng ...> 340*83a54b2fSSadaf Ebrahimi ... 341*83a54b2fSSadaf Ebrahimi <reporter classname="com.test.MyReporter"> 342*83a54b2fSSadaf Ebrahimi <property name="methodFilter" value="*insert*"/> 343*83a54b2fSSadaf Ebrahimi <property name="enableFiltering" value="true"/> 344*83a54b2fSSadaf Ebrahimi </reporter> 345*83a54b2fSSadaf Ebrahimi ... 346*83a54b2fSSadaf Ebrahimi</testng> 347*83a54b2fSSadaf Ebrahimi</pre> 348*83a54b2fSSadaf Ebrahimi<pre class="brush: java"> 349*83a54b2fSSadaf Ebrahimipublic class MyReporter { 350*83a54b2fSSadaf Ebrahimi 351*83a54b2fSSadaf Ebrahimi public String getMethodFilter() {...} 352*83a54b2fSSadaf Ebrahimi public void setMethodFilter(String methodFilter) {...} 353*83a54b2fSSadaf Ebrahimi public boolean isEnableFiltering() {...} 354*83a54b2fSSadaf Ebrahimi public void setEnableFiltering(boolean enableFiltering) {...} 355*83a54b2fSSadaf Ebrahimi ... 356*83a54b2fSSadaf Ebrahimi} 357*83a54b2fSSadaf Ebrahimi</pre> 358*83a54b2fSSadaf EbrahimiYou have to consider though that for the moment only a limited set of property types are supported: 359*83a54b2fSSadaf Ebrahimi<tt>String, int, boolean, byte, char, double, float, long, short</tt>. 360*83a54b2fSSadaf Ebrahimi 361*83a54b2fSSadaf Ebrahimi<h4>env</h4> 362*83a54b2fSSadaf Ebrahimi<p>It is possible to specify environment variables to pass to the TestNG forked 363*83a54b2fSSadaf Ebrahimivirtual machine via nested <tt><env></tt> elements. For a description of the <tt> 364*83a54b2fSSadaf Ebrahimi<env></tt> element's attributes, see the description in the <em> 365*83a54b2fSSadaf Ebrahimi<a href="http://ant.apache.org/manual/CoreTasks/exec.html">exec</a></em> task.</p> 366*83a54b2fSSadaf Ebrahimi<h3>Examples</h3> 367*83a54b2fSSadaf Ebrahimi<h4>Suite xml</h4> 368*83a54b2fSSadaf Ebrahimi 369*83a54b2fSSadaf Ebrahimi<pre class="brush: text"> 370*83a54b2fSSadaf Ebrahimi<testng classpathref="run.cp" 371*83a54b2fSSadaf Ebrahimi outputDir="${testng.report.dir}" 372*83a54b2fSSadaf Ebrahimi sourcedir="${test.src.dir}" 373*83a54b2fSSadaf Ebrahimi haltOnfailure="true"> 374*83a54b2fSSadaf Ebrahimi 375*83a54b2fSSadaf Ebrahimi <xmlfileset dir="${test14.dir}" includes="testng.xml"/> 376*83a54b2fSSadaf Ebrahimi</testng> 377*83a54b2fSSadaf Ebrahimi</pre> 378*83a54b2fSSadaf Ebrahimi 379*83a54b2fSSadaf Ebrahimi<h4>Class FileSet</h4> 380*83a54b2fSSadaf Ebrahimi<pre class="brush: xml"> 381*83a54b2fSSadaf Ebrahimi<testng classpathref="run.cp" 382*83a54b2fSSadaf Ebrahimi outputDir="${testng.report.dir}" 383*83a54b2fSSadaf Ebrahimi haltOnFailure="true" verbose="2"> 384*83a54b2fSSadaf Ebrahimi <classfileset dir="${test.build.dir}" includes="**/*.class" /> 385*83a54b2fSSadaf Ebrahimi</testng> 386*83a54b2fSSadaf Ebrahimi</pre> 387*83a54b2fSSadaf Ebrahimi 388*83a54b2fSSadaf Ebrahimi<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> 389*83a54b2fSSadaf Ebrahimi</script> 390*83a54b2fSSadaf Ebrahimi<script type="text/javascript"> 391*83a54b2fSSadaf Ebrahimi_uacct = "UA-238215-2"; 392*83a54b2fSSadaf EbrahimiurchinTracker(); 393*83a54b2fSSadaf Ebrahimi</script> 394*83a54b2fSSadaf Ebrahimi 395*83a54b2fSSadaf Ebrahimi</body> 396*83a54b2fSSadaf Ebrahimi 397*83a54b2fSSadaf Ebrahimi</html> 398