Wednesday 5 June 2013

Sample Testng.xml when we use groups


This post demonstrates a simple example of using groups with TestNG.

For this exercise I’m using a very simple file layout. and assuming the project is already setup

 Sample Testng.xml


<?xml version="1.0" encoding="UTF-8"?>
   
    <suite name="MySeleniumAutomation" verbose="1" >
<test name="Homepage" enabled="true">
<groups>
<run>
<include name="IEConfiguration"/>
<include name="FFConfiguration"/>
</run>
</groups>

<classes>
          <class name="net.mss.TestNGxslt.Homepage"/>
</classes>
</test>   

</suite>
        Consider we have a one test suite named MySelniumAutoamtion in that we have two classes HomePage and LoginPage classes
Now in Each class we have 3 tests to perform same operation in different browsers likely IE,chrome and FF.
No if u want to run the test suite in IE only  then we use Groups
For that we need to Create one group  like following way

@Test(priority=0,groups={"IEConfiguration"} )

 Groups are most helpful when we want to execute more than one test which are there in different classes

NOTE:  when we running test that are there in different classes we need to add AlwaysRun attribute to BeforeMethod and AfterMethod..
like
@BeforeMethod(alwaysRun = true)
@AfterMethod(alwaysRun = true)

   
   

No comments:

Post a Comment