1 package test.methodselectors; 2 3 import org.testng.IMethodSelector; 4 import org.testng.IMethodSelectorContext; 5 import org.testng.ITestNGMethod; 6 7 import java.util.List; 8 9 public class Test2MethodSelector implements IMethodSelector { 10 11 /** 12 * 13 */ 14 private static final long serialVersionUID = 4166247968392649912L; 15 16 @Override includeMethod(IMethodSelectorContext context, ITestNGMethod method, boolean isTestMethod)17 public boolean includeMethod(IMethodSelectorContext context, 18 ITestNGMethod method, boolean isTestMethod) 19 { 20 for (String group : method.getGroups()) { 21 if (group.equals("test2")) { 22 context.setStopped(true); 23 return true; 24 } 25 } 26 27 return false; 28 } 29 30 @Override setTestMethods(List<ITestNGMethod> testMethods)31 public void setTestMethods(List<ITestNGMethod> testMethods) { 32 // TODO Auto-generated method stub 33 34 } 35 36 } 37