Sunday, 13 October 2013

Run multi-tests with multiple instances of Firefox at the same time | TestNG

No need of Grid to execute multiple instances of Firefox at the same time.  Make sure TestNG in your buildpath.

Create .xml file and replace the code

Right-click on your Project/Class file > TestNG > "Convert to TestNG" > Repalce with the xml code given below > Finish

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" verbose="1" parallel="tests">
  <test name="Test1"> 
    <classes>
      <class name="package.classname1"/>
    </classes>
  </test> <!-- Test -->
  <test name="Test2"> 
    <classes>
      <class name="package.classname2"/>
    </classes>
  </test> <!-- Test --> 
</suite> <!-- Suite -->

Now run the TestNG framework

Right-click testng.xml file from your Project > Run As > TestNG Suite

For Example, if you have couple|more tests in a same class repalce with the xml code given below,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" verbose="1" parallel="tests">
  <test name="Test1"> 
    <classes>
      <class name="package.classname">
      <methods>
<include name="test01"></include>
      </methods>
      </class>
    </classes>
  </test> <!-- Test -->

  <test name="Test2"> 
    <classes>
      <class name="package.classname">
      <methods>
<include name="test02"></include>
      </methods>
      </class>
    </classes>
  </test> <!-- Test -->
  
</suite> <!-- Suite -->





1 comment: