1*83a54b2fSSadaf Ebrahimi<html> 2*83a54b2fSSadaf Ebrahimi <head> 3*83a54b2fSSadaf Ebrahimi <title>TestNG - Eclipse</title> 4*83a54b2fSSadaf Ebrahimi <script type="text/javascript" src="banner.js"></script> 5*83a54b2fSSadaf Ebrahimi <link rel="stylesheet" href="testng.css" type="text/css" /> 6*83a54b2fSSadaf Ebrahimi </head> 7*83a54b2fSSadaf Ebrahimi<body> 8*83a54b2fSSadaf Ebrahimi 9*83a54b2fSSadaf Ebrahimi<script type="text/javascript"> 10*83a54b2fSSadaf Ebrahimi displayMenu("eclipse.html") 11*83a54b2fSSadaf Ebrahimi</script> 12*83a54b2fSSadaf Ebrahimi 13*83a54b2fSSadaf Ebrahimi 14*83a54b2fSSadaf Ebrahimi<h2 align="center">TestNG Eclipse plug-in</h2> 15*83a54b2fSSadaf Ebrahimi<p>The TestNG Eclipse plug-in allows you to run your TestNG tests from Eclipse 16*83a54b2fSSadaf Ebrahimiand easily monitor their execution and their output. It has its own <a href="http://github.com/cbeust/testng-eclipse">project repository called <tt>testng-eclipse</tt></a>.</p> 17*83a54b2fSSadaf Ebrahimi 18*83a54b2fSSadaf Ebrahimi 19*83a54b2fSSadaf Ebrahimi<h3>Table of Contents</h3> 20*83a54b2fSSadaf Ebrahimi 21*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-installation">1 - Installation</a> 22*83a54b2fSSadaf Ebrahimi<br> 23*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-creating">2 - Creating a TestNG class</a> 24*83a54b2fSSadaf Ebrahimi<br> 25*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-create-launch">3 - Launch configurations</a> 26*83a54b2fSSadaf Ebrahimi<br> 27*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-create-class">3.1 - From a class file</a> 28*83a54b2fSSadaf Ebrahimi<br> 29*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-create-groups">3.2 - From groups</a> 30*83a54b2fSSadaf Ebrahimi<br> 31*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-create-xml">3.3 - From an XML file</a> 32*83a54b2fSSadaf Ebrahimi<br> 33*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-create-method">3.4 - From a method</a> 34*83a54b2fSSadaf Ebrahimi<br> 35*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-listeners">3.5 - Specifying listeners and other settings</a> 36*83a54b2fSSadaf Ebrahimi<br> 37*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-viewing">4 - Viewing the results</a> 38*83a54b2fSSadaf Ebrahimi<br> 39*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-search">5 - Search</a> 40*83a54b2fSSadaf Ebrahimi<br> 41*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-summary">6 - The Summary tab</a> 42*83a54b2fSSadaf Ebrahimi<br> 43*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-quickfix">7 - Converting JUnit tests</a> 44*83a54b2fSSadaf Ebrahimi<br> 45*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-quickfixes">8 - Quick fixes</a> 46*83a54b2fSSadaf Ebrahimi<br> 47*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-preferences">9 - Preferences and Properties</a> 48*83a54b2fSSadaf Ebrahimi<br> 49*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-workbench-preferences">9.1 - Workbench Preferences</a> 50*83a54b2fSSadaf Ebrahimi<br> 51*83a54b2fSSadaf Ebrahimi <a class="summary" href="#eclipse-project-properties">9.2 - Project Properties</a> 52*83a54b2fSSadaf Ebrahimi<br> 53*83a54b2fSSadaf Ebrahimi <a class="summary" href="#testng-xml"></a> 54*83a54b2fSSadaf Ebrahimi 55*83a54b2fSSadaf Ebrahimi<!-- 56*83a54b2fSSadaf Ebrahimi Installation 57*83a54b2fSSadaf Ebrahimi--> 58*83a54b2fSSadaf Ebrahimi<h3><a name="eclipse-installation">1 - Installation</a></h3><p> 59*83a54b2fSSadaf EbrahimiOnce you have <a href="http://testng.org/doc/download.html">installed the plug-in</a>, restart Eclipse and select the menu <tt>Window / Show View 60*83a54b2fSSadaf Ebrahimi/ Other...</tt> and you should see the TestNG view listed in the Java category.</p><p align="center"> 61*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/view.png" /> 62*83a54b2fSSadaf Ebrahimi</p> 63*83a54b2fSSadaf Ebrahimi<p> 64*83a54b2fSSadaf EbrahimiNOTE: since TestNG Eclipse Plugin 6.9.8, the minimum required TestNG version is <b>6.5.1</b> 65*83a54b2fSSadaf Ebrahimi</p> 66*83a54b2fSSadaf Ebrahimi 67*83a54b2fSSadaf Ebrahimi<!-- 68*83a54b2fSSadaf Ebrahimi Creating 69*83a54b2fSSadaf Ebrahimi--> 70*83a54b2fSSadaf Ebrahimi<h3><a name="eclipse-creating">2 - Creating a TestNG class</a></h3><p> 71*83a54b2fSSadaf Ebrahimi 72*83a54b2fSSadaf EbrahimiTo create a new TestNG class, select the menu File / New / TestNG: 73*83a54b2fSSadaf Ebrahimi 74*83a54b2fSSadaf Ebrahimi<p align="center"> 75*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/new-1.png" /> 76*83a54b2fSSadaf Ebrahimi</p> 77*83a54b2fSSadaf Ebrahimi 78*83a54b2fSSadaf EbrahimiIf you currently have a Java file open in the editor or if you have a Java file selected in the Navigator, the first page of the wizard will show you a list of all the public methods of that class and it will give you the option to select the ones you want to test. Each method you select on this page will be included in the new TestNG class with a default implementation that throws an exception, so you remember to implement it. 79*83a54b2fSSadaf Ebrahimi 80*83a54b2fSSadaf Ebrahimi<p align="center"> 81*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/new-2.png" /> 82*83a54b2fSSadaf Ebrahimi</p> 83*83a54b2fSSadaf Ebrahimi 84*83a54b2fSSadaf EbrahimiThe next page lets you specify where that file will be created, whether it should contain default implementation for some configuration methods, if you'd like a data provider and finally, if a <tt>testng.xml</tt> file should be generated. 85*83a54b2fSSadaf Ebrahimi 86*83a54b2fSSadaf Ebrahimi<p align="center"> 87*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/new-3.png" /> 88*83a54b2fSSadaf Ebrahimi</p> 89*83a54b2fSSadaf Ebrahimi 90*83a54b2fSSadaf EbrahimiThe plug-in will make a guess about the best location where this file should be created (for example, if you are using Maven, the default location will be under <tt>src/test/java</tt>). 91*83a54b2fSSadaf Ebrahimi 92*83a54b2fSSadaf Ebrahimi<h3><a name="eclipse-create-launch">3 - Launch configuration</a></h3><p>Once you have created classes that contain TestNG annotations and/or one or 93*83a54b2fSSadaf Ebrahimimore <tt>testng.xml</tt> files, you can create a TestNG Launch Configuration. 94*83a54b2fSSadaf EbrahimiSelect the <tt>Run / Run...</tt> (or <tt>Run / Debug...</tt>) menu and create a new TestNG 95*83a54b2fSSadaf Ebrahimiconfiguration:</p><p align="center"> 96*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/launch.png" /> 97*83a54b2fSSadaf Ebrahimi</p> 98*83a54b2fSSadaf Ebrahimi<p>You should change the name of this configuration and pick a project, which 99*83a54b2fSSadaf Ebrahimican be selected by clicking on the <tt>Browse...</tt> button at the top of the window.</p> 100*83a54b2fSSadaf Ebrahimi<p> 101*83a54b2fSSadaf EbrahimiRuntime options: 102*83a54b2fSSadaf Ebrahimi<ul> 103*83a54b2fSSadaf Ebrahimi<li><b>Log Level</b>: specify the value (0-10) for different verbose log levels</li> 104*83a54b2fSSadaf Ebrahimi<li><b>Verbose</b>: enable the runtime TestNG verbose log</li> 105*83a54b2fSSadaf Ebrahimi<li><b>Debug</b>: enable more runtime TestNG debug info</li> 106*83a54b2fSSadaf Ebrahimi<li><b>Serialization Protocol</b>: the serialization protocol used for communicating between TestNG Eclipse Plugin and TestNG runtime. 107*83a54b2fSSadaf EbrahimiThe default is "Object Serialization", the other option ("String Serialization") is deprecated.</li> 108*83a54b2fSSadaf Ebrahimi<li><b>Add the POM's JVM Arguments when launch</b>: for maven based project, we normally define maven-surefire-plugin for test phase and maven-failsafe-plugin for integration test phase, there might be having the testing runtime JVM arguments defined in the "argLine" element of the maven plugin configuration. If you check this option, TestNG Eclipse Plugin will try to recognize the JVM arguments in "argLine", add them to TestNG runtime JVM arguments when launch.<br/> 109*83a54b2fSSadaf EbrahimiNOTE 1: these JVM arguments are put on front of user defined VM arguments on "Arguments" tab, which means you can overide the POM defined JVM argumetns with the ones on "Arguments" tab.<br/> 110*83a54b2fSSadaf EbrahimiNOTE 2: if there are multiple "argLine" elements in the pom.xml, the first presence will be used. If it's not the desired behaviour, you can simply uncheck this option, and type your JVM arguments on the "Arguments" tab next to this "Test" tab.</li> 111*83a54b2fSSadaf Ebrahimi</ul> 112*83a54b2fSSadaf Ebrahimi</p> 113*83a54b2fSSadaf Ebrahimi<p>Then you choose to launch your TestNG tests in the following ways:</p><h4><a name="eclipse-launch-class">4.2.1 - From a class file</a></h4><p>Make sure the box near <tt>Class</tt> is checked and then pick a class from your 114*83a54b2fSSadaf Ebrahimiproject. You can click on the <tt>Browse...</tt> button and pick it directly from a 115*83a54b2fSSadaf Ebrahimilist. This list only contains classes that contain TestNG annotations:</p><p align="center"> 116*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/classes.png" /> 117*83a54b2fSSadaf Ebrahimi</p> 118*83a54b2fSSadaf Ebrahimi 119*83a54b2fSSadaf Ebrahimi 120*83a54b2fSSadaf Ebrahimi<h4><a name="eclipse-create-groups">3.2 - From groups</a></h4> 121*83a54b2fSSadaf Ebrahimi<p>If you only want to launch one or several groups, you can type them in the 122*83a54b2fSSadaf Ebrahimitext field or pick them from a list by clicking on the <tt>Browse...</tt> button 123*83a54b2fSSadaf Ebrahimi 124*83a54b2fSSadaf Ebrahimi<p align="center"> 125*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/groups.png" /> 126*83a54b2fSSadaf Ebrahimi</p> 127*83a54b2fSSadaf Ebrahimi 128*83a54b2fSSadaf Ebrahimi 129*83a54b2fSSadaf Ebrahimi<h4><a name="eclipse-create-xml">3.3 - From a definition file</a></h4> 130*83a54b2fSSadaf EbrahimiFinally, you can select a suite definition from your project. It doesn't have to be named 131*83a54b2fSSadaf Ebrahimi<tt>testng.xml</tt>, the plug-in will automatically identify all the applicable TestNG XML files 132*83a54b2fSSadaf Ebrahimiin your project: 133*83a54b2fSSadaf Ebrahimi<p align="center"> 134*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/suites.png" /> 135*83a54b2fSSadaf Ebrahimi</p> 136*83a54b2fSSadaf EbrahimiYou can type the regex on the filter text field to narrow down to suite definition files matching your search from a long list of files. 137*83a54b2fSSadaf Ebrahimi 138*83a54b2fSSadaf Ebrahimi<h4> 139*83a54b2fSSadaf Ebrahimi<a name="eclipse-create-method">3.4 - From a method </a> 140*83a54b2fSSadaf Ebrahimi</h4> 141*83a54b2fSSadaf Ebrahimi<p>This launch isn't accomplished from the Launch dialog but 142*83a54b2fSSadaf Ebrahimidirectly from your Outline view:</p><p align="center"> 143*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/outline.png" /> 144*83a54b2fSSadaf Ebrahimi</p> 145*83a54b2fSSadaf EbrahimiYou can right-click on any test methods and select <tt>Run as... / TestNG test</tt> and only the selected 146*83a54b2fSSadaf Ebrahimimethod will be run (not shown on the above screenshot because I couldn't find a way to capture 147*83a54b2fSSadaf Ebrahimia contextual menu).<p>Method launching is also available from the Package 148*83a54b2fSSadaf EbrahimiExplorer view and from the Java Browser perspective.</p><p>Once you have selected one of these launches, you can also choose the logging of level. Then you can launch the tests by pressing the <tt>Debug</tt> (or <tt>Run</tt>) button, which will switch you to the Debug perspective and will open the main TestNG view.</p> 149*83a54b2fSSadaf Ebrahimi 150*83a54b2fSSadaf Ebrahimi<h4> 151*83a54b2fSSadaf Ebrahimi<a name="eclipse-listeners">3.5 -Specifying listeners and other settings </a> 152*83a54b2fSSadaf Ebrahimi</h4> 153*83a54b2fSSadaf Ebrahimi 154*83a54b2fSSadaf EbrahimiAs you saw above, the plug-in will let you start tests in many different ways: from an XML file, from a method, a class, etc... When you are running an XML file, you can specify all the settings you want for this run in the XML file, but what if you want to run a package in parallel mode with specific listeners? How can you configure the settings for all the launches that are not done from an XML file? 155*83a54b2fSSadaf Ebrahimi 156*83a54b2fSSadaf Ebrahimi<p> 157*83a54b2fSSadaf Ebrahimi 158*83a54b2fSSadaf EbrahimiIn order to give you access to the most flexibility, TestNG lets you specify an XML suite file for all these launches, which you can find in the Preferences menu: 159*83a54b2fSSadaf Ebrahimi 160*83a54b2fSSadaf Ebrahimi<p align="center"> 161*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/template.png"/> 162*83a54b2fSSadaf Ebrahimi</p> 163*83a54b2fSSadaf Ebrahimi 164*83a54b2fSSadaf EbrahimiIf you specify a valid suite file as "XML template file", TestNG will reuse all the settings found in this XML file, such as parallel, name, listeners, thread pool size, etc... Only the <tt><test></tt> tags in this file will be ignored since the plug-in will replace these by a generated <tt><test></tt> tag that represents the launch you chose. 165*83a54b2fSSadaf Ebrahimi 166*83a54b2fSSadaf Ebrahimi<!-- 167*83a54b2fSSadaf Ebrahimi Viewing 168*83a54b2fSSadaf Ebrahimi--> 169*83a54b2fSSadaf Ebrahimi<h3> 170*83a54b2fSSadaf Ebrahimi<a name="eclipse-viewing">4 - Viewing the test results </a> 171*83a54b2fSSadaf Ebrahimi</h3> 172*83a54b2fSSadaf Ebrahimi 173*83a54b2fSSadaf Ebrahimi<p align="center"> 174*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/success.png" /> 175*83a54b2fSSadaf Ebrahimi</p> 176*83a54b2fSSadaf Ebrahimi 177*83a54b2fSSadaf Ebrahimi<p>The above view shows a successful run of the tests: the bar is green 178*83a54b2fSSadaf Ebrahimiand no failed tests are reported. The <tt>All tests</tt> tab shows you a list of 179*83a54b2fSSadaf Ebrahimiall the classes and methods that were run.</p><p>If your test run contains failures, the view will look like this:</p><p align="center"> 180*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/failure.png" /> 181*83a54b2fSSadaf Ebrahimi</p> 182*83a54b2fSSadaf Ebrahimi 183*83a54b2fSSadaf Ebrahimi<p>You can use the <tt>Failed tests</tt> tab to display only these tests that failed, and 184*83a54b2fSSadaf Ebrahimiwhen you select such a test, the stack trace will be shown on the right-hand 185*83a54b2fSSadaf Ebrahimipane. You can double click on the offending line to be taken directly to 186*83a54b2fSSadaf Ebrahimithe failure in your code.</p> 187*83a54b2fSSadaf Ebrahimi 188*83a54b2fSSadaf Ebrahimi<h3> 189*83a54b2fSSadaf Ebrahimi<a name="eclipse-search">5 - Search </a> 190*83a54b2fSSadaf Ebrahimi</h3> 191*83a54b2fSSadaf Ebrahimi 192*83a54b2fSSadaf Ebrahimi 193*83a54b2fSSadaf Ebrahimi<p align="center"> 194*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/search.png" /> 195*83a54b2fSSadaf Ebrahimi</p> 196*83a54b2fSSadaf Ebrahimi 197*83a54b2fSSadaf Ebrahimi<p>When you have hundreds of tests running, finding a specific one is not always easy, so you can type a few letters of the test method or its parameters in the Search box and the content of the tree will automatically narrow down to methods matching your search. Note in the screen shot above that the search also works on parameters provided by <tt>@DataProvider</tt>.</p> 198*83a54b2fSSadaf Ebrahimi 199*83a54b2fSSadaf Ebrahimi<h3> 200*83a54b2fSSadaf Ebrahimi<a name="eclipse-summary">6 - Summary </a> 201*83a54b2fSSadaf Ebrahimi</h3> 202*83a54b2fSSadaf Ebrahimi 203*83a54b2fSSadaf Ebrahimi 204*83a54b2fSSadaf Ebrahimi<p align="center"> 205*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/summary1.png" /> 206*83a54b2fSSadaf Ebrahimi</p> 207*83a54b2fSSadaf Ebrahimi<p>The Summary tab gives you statistics on your test run, such as the timings, the test names, the number of methods and classes, etc… Since the results are shown in a table, you can also sort on any criterion you like for easier parsing. This is especially handy when you are trying to determine what tests take the longest time.</p> 208*83a54b2fSSadaf Ebrahimi 209*83a54b2fSSadaf Ebrahimi<p>The search box works in this view as well, and note that in the screen shot below, the Time column is sorted in decreasing order:</p> 210*83a54b2fSSadaf Ebrahimi<p align="center"> 211*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/summary2.png" /> 212*83a54b2fSSadaf Ebrahimi 213*83a54b2fSSadaf Ebrahimi 214*83a54b2fSSadaf Ebrahimi 215*83a54b2fSSadaf Ebrahimi<h3><a name="eclipse-quickfix">7 - Converting JUnit tests</a></h3> 216*83a54b2fSSadaf Ebrahimi 217*83a54b2fSSadaf EbrahimiYou can easily convert JUnit 3 and JUnit 4 tests to TestNG. 218*83a54b2fSSadaf Ebrahimi 219*83a54b2fSSadaf Ebrahimi<p> 220*83a54b2fSSadaf Ebrahimi 221*83a54b2fSSadaf EbrahimiYour first option is to use the Quick Fix function: 222*83a54b2fSSadaf Ebrahimi 223*83a54b2fSSadaf Ebrahimi<p> 224*83a54b2fSSadaf Ebrahimi 225*83a54b2fSSadaf Ebrahimi<p align="center"> 226*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/convert1.png" /> 227*83a54b2fSSadaf Ebrahimi<br> 228*83a54b2fSSadaf Ebrahimi<b>Convert from JUnit 3</b> 229*83a54b2fSSadaf Ebrahimi</p> 230*83a54b2fSSadaf Ebrahimi 231*83a54b2fSSadaf Ebrahimi<p align="center"> 232*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/convert2.png" /> 233*83a54b2fSSadaf Ebrahimi<br> 234*83a54b2fSSadaf Ebrahimi<b>Convert from JUnit 4</b> 235*83a54b2fSSadaf Ebrahimi</p> 236*83a54b2fSSadaf Ebrahimi 237*83a54b2fSSadaf EbrahimiYou can also convert packages or entire source folders with the conversion refactoring: 238*83a54b2fSSadaf Ebrahimi 239*83a54b2fSSadaf Ebrahimi<p align="center"> 240*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/refactoring1.png" /> 241*83a54b2fSSadaf Ebrahimi</p> 242*83a54b2fSSadaf Ebrahimi 243*83a54b2fSSadaf EbrahimiThe refactoring wizard contains several pages: 244*83a54b2fSSadaf Ebrahimi 245*83a54b2fSSadaf Ebrahimi<p align="center"> 246*83a54b2fSSadaf Ebrahimi<img border="0" src="http://beust.com/pics/menu-convert2.png " /> 247*83a54b2fSSadaf Ebrahimi</p> 248*83a54b2fSSadaf Ebrahimi 249*83a54b2fSSadaf EbrahimiThis page lets you generate a testng.xml automatically. You can configure whether to include your test classes individually or by package, the suite and test name and also whether these tests should run in parallel. 250*83a54b2fSSadaf Ebrahimi 251*83a54b2fSSadaf Ebrahimi<p align="center"> 252*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/refactoring2.png" /> 253*83a54b2fSSadaf Ebrahimi</p> 254*83a54b2fSSadaf Ebrahimi 255*83a54b2fSSadaf EbrahimiThis page gives you an overview of the changes that are about to be performed. You can also decide to exclude certain files from the refactoring. 256*83a54b2fSSadaf Ebrahimi 257*83a54b2fSSadaf Ebrahimi<p> 258*83a54b2fSSadaf Ebrahimi 259*83a54b2fSSadaf EbrahimiWhen you are done, press the "Finish" button. Like all Eclipse refactorings, you can undo all these changes in one click: 260*83a54b2fSSadaf Ebrahimi 261*83a54b2fSSadaf Ebrahimi<p align="center"> 262*83a54b2fSSadaf Ebrahimi<img border="0" src="http://beust.com/pics/menu-convert4.png" /> 263*83a54b2fSSadaf Ebrahimi</p> 264*83a54b2fSSadaf Ebrahimi 265*83a54b2fSSadaf Ebrahimi<h3><a name="eclipse-quickfixes">8 - Quick fixes</a></h3> 266*83a54b2fSSadaf Ebrahimi 267*83a54b2fSSadaf EbrahimiThe TestNG Eclipse plug-in offers several quick fixes while you are editing a TestNG class (accessible with <tt>Ctrl-1</tt> on Windows/Linux and <tt>⌘-1</tt> on Mac OS): 268*83a54b2fSSadaf Ebrahimi 269*83a54b2fSSadaf Ebrahimi<h4>Convert to JUnit</h4> 270*83a54b2fSSadaf Ebrahimi 271*83a54b2fSSadaf EbrahimiThis was covered in the <a href="#eclipse-quickfix"> previous section</a>. 272*83a54b2fSSadaf Ebrahimi 273*83a54b2fSSadaf Ebrahimi<h4>Pushing and pulling <tt>@Test</tt> annotations</h4> 274*83a54b2fSSadaf Ebrahimi 275*83a54b2fSSadaf EbrahimiIf you have several test methods annotated with <tt>@Test</tt> and you'd like to replace them all with a single <tt>@Test</tt> annotation at the class level, choose the "Pull annotation" quick fix: 276*83a54b2fSSadaf Ebrahimi 277*83a54b2fSSadaf Ebrahimi<p align="center"> 278*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/refactoring-pull-annotation.png" /> 279*83a54b2fSSadaf Ebrahimi</p> 280*83a54b2fSSadaf Ebrahimi 281*83a54b2fSSadaf EbrahimiReciprocally, you can move a class level <tt>@Test</tt> annotation onto all your public methods: 282*83a54b2fSSadaf Ebrahimi 283*83a54b2fSSadaf Ebrahimi<p align="center"> 284*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/refactoring-push-annotation.png" /> 285*83a54b2fSSadaf Ebrahimi</p> 286*83a54b2fSSadaf Ebrahimi 287*83a54b2fSSadaf Ebrahimi<h4>Automatically importing <tt>asserts</tt></h4> 288*83a54b2fSSadaf Ebrahimi 289*83a54b2fSSadaf EbrahimiApply a quick fix on an assert method to automatically import it: 290*83a54b2fSSadaf Ebrahimi 291*83a54b2fSSadaf Ebrahimi<p align="center"> 292*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/quickfix-import.png" /> 293*83a54b2fSSadaf Ebrahimi</p> 294*83a54b2fSSadaf Ebrahimi 295*83a54b2fSSadaf Ebrahimi<!-- 296*83a54b2fSSadaf Ebrahimi Preferences and Properties 297*83a54b2fSSadaf Ebrahimi--> 298*83a54b2fSSadaf Ebrahimi<h3><a name="eclipse-preferences">9 - Preferences and Properties</a></h3> 299*83a54b2fSSadaf Ebrahimi<h4><a name="eclipse-workbench-preferences">9.1 - Workbench Preferences</a></h4> 300*83a54b2fSSadaf EbrahimiTestNG workbench preferences: 301*83a54b2fSSadaf Ebrahimi<p align="center"> 302*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/preferences.png" /> 303*83a54b2fSSadaf Ebrahimi</p> 304*83a54b2fSSadaf Ebrahimi<p> 305*83a54b2fSSadaf EbrahimiThe preferences here are shared among projects and launch configurations. 306*83a54b2fSSadaf Ebrahimi<ul> 307*83a54b2fSSadaf Ebrahimi<li><b>Output directory</b>: the path where to store the output including temp files, report files, etc. By default, the path is relative to each project except you check the option <b>Absolute ouput path</b> below.</li> 308*83a54b2fSSadaf Ebrahimi<li><b>Disalbe default listeners</b>: disable the default listeners when launch testng runtime</li> 309*83a54b2fSSadaf Ebrahimi<li><b>Show view when test complete</b>: active the TestNG result view when the test complete</li> 310*83a54b2fSSadaf Ebrahimi<li><b>Use Project TestNG jar</b>: It's default to be checked which means TestNG Eclipse Plugin will use the project TestNG jar (for example, the TestNG version managed with maven) when launch TestNG runtime. Otherwise, the TestNG eclipse plugin embedded TestNG version will be used.<br/> 311*83a54b2fSSadaf EbrahimiWhen to check this option? 312*83a54b2fSSadaf Ebrahimi<ul> 313*83a54b2fSSadaf Ebrahimi <li>you want it behviour as close as running outside IDE, e.g. with maven surefire plugin, since the Plugin embedded version of TestNG most likely different with the version of your project.</li> 314*83a54b2fSSadaf Ebrahimi <li>you don't want the Plugin embedded plugin and it's dependent libs (e.g. snakeyaml, etc.) pollute your TestNG runtime classpath.</li> 315*83a54b2fSSadaf Ebrahimi</ul></li> 316*83a54b2fSSadaf Ebrahimi<li><b>Template XML file</b>: the absolute path of the template xml file used to genernate the custom test suite xml before launch</li> 317*83a54b2fSSadaf Ebrahimi<li><b>Excluded stack traces</b>: </li> 318*83a54b2fSSadaf Ebrahimi<li><b>Pre Defined Listeners</b>: </li> 319*83a54b2fSSadaf Ebrahimi</ul> 320*83a54b2fSSadaf Ebrahimi</p> 321*83a54b2fSSadaf Ebrahimi 322*83a54b2fSSadaf Ebrahimi<h4><a name="eclipse-project-properties">9.2 - Project Properties</a></h4> 323*83a54b2fSSadaf EbrahimiProject level properties: 324*83a54b2fSSadaf Ebrahimi<p align="center"> 325*83a54b2fSSadaf Ebrahimi<img border="0" src="http://testng.org/pictures/project_properties.png" /> 326*83a54b2fSSadaf Ebrahimi</p> 327*83a54b2fSSadaf Ebrahimi<p> 328*83a54b2fSSadaf EbrahimiHere are properties on each project level, it will override the same properties if defined in <a class="summary" href="#eclipse-workbench-preferences">TestNG workbench preferences</a> 329*83a54b2fSSadaf Ebrahimi<ul> 330*83a54b2fSSadaf Ebrahimi<li><b>Output directory</b>: for example, in the figure above, I prefer to put the output to maven 'target' directory rather than the default one under project root</li> 331*83a54b2fSSadaf Ebrahimi<li><b>Watch testng-result.xml</b>:</li> 332*83a54b2fSSadaf Ebrahimi<li><b>Template XML file</b>: see in <a class="summary" href="#eclipse-workbench-preferences">TestNG workbench preferences</a></li> 333*83a54b2fSSadaf Ebrahimi<li><b>Use Project TestNG jar</b>: see in <a class="summary" href="#eclipse-workbench-preferences">TestNG workbench preferences</a></li> 334*83a54b2fSSadaf Ebrahimi<li><b>Pre Defined Listeners</b>: see in <a class="summary" href="#eclipse-workbench-preferences">TestNG workbench preferences</a></li> 335*83a54b2fSSadaf Ebrahimi</ul> 336*83a54b2fSSadaf Ebrahimi</p> 337*83a54b2fSSadaf Ebrahimi 338*83a54b2fSSadaf Ebrahimi<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> 339*83a54b2fSSadaf Ebrahimi</script> 340*83a54b2fSSadaf Ebrahimi<script type="text/javascript"> 341*83a54b2fSSadaf Ebrahimi_uacct = "UA-238215-2"; 342*83a54b2fSSadaf EbrahimiurchinTracker(); 343*83a54b2fSSadaf Ebrahimi</script> 344*83a54b2fSSadaf Ebrahimi 345*83a54b2fSSadaf Ebrahimi</body>