Sunday, 7 February 2016

Selenium:Specifying multiple groups at test method level

Specifying multiple groups at test method level:
====================================
package testngdemo;

import org.testng.annotations.Test;

public class GroupDemo {

@Test(groups={"regression"})
public void testScript1() {
System.out.println("regression");

}

@Test(groups="regression")
public void testScript2() {
System.out.println("regression");

}
@Test(groups="regression")
public void testScript3() {
System.out.println("regression");

}
@Test(groups={"regression","smoketesting"})
public void testScript4() {
System.out.println("regression,smoketesting");

}
@Test(groups="smoketesting")
public void testScript5() {
System.out.println("smoketesting");

}
}


testng.xml:
=========
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
  <test name="Test">
  <groups>
         <define name="all">
            <include name="regression"/>
            <exclude name="smoketesting"/>
         </define>

         <run>
            <include name="all"/>
         </run>
      </groups>
    <classes>
      <class name="testngdemo.GroupDemo"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

No comments:

Post a Comment