Skip to content
freynaud edited this page Nov 16, 2011 · 3 revisions

Jenkins example

the [user documentation] (https://github.com/freynaud/testng-support/wiki/User-documentation) explains how to run everything from your IDE.

To run the same tests in a CI, you need generate the testng.xml file corresponding to the test you want to run, plug it in your pom.xml and create a maven based job.

Creating testng.xml file to run the test is documented on the testNG site : testng.org so I will only mention the part that are specific to the selenium integration :

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
 <suite thread-count="50" verbose="0" name="test suite" parallel="methods" data-provider-thread-count="50">

 <!-- specify the parameters -> 
 <parameter name="browserName" value="firefox"/>
 <!-- and the hub ->
 <parameter name="url" value="http://localhost:4444/wd/hub"></parameter>

 <!-- plug the listeners ->
   <listeners>
     <listener class-name="org.openqa.selenium.support.testng.SeleniumCapability"/>
     <listener class-name="org.openqa.selenium.support.testng.LocalGrid"/>
   </listeners>

 <!-- normal testng def from there ->
   <test>
     <classes>
       <class name="DemoSeleniumLegacy">
         <methods>
           <include name="test2"/>
         </methods>
       </class>
     </classes>
   </test>
 </suite>

To keep the example simple, only the browser name is specified. You can also specify the version, OS etc.

If you want to run the same suite with different browser combination, an easy way of doing that is to add some logic in the listener SeleniumCapability and add some logic to have system parameters overwriting the testNG provided parameters.

That way you can use the jenkins UI to specify those parameters.

// screen.

Clone this wiki locally