--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/f565261e-9612-43b5-bc41-8eaad8125aaen%40googlegroups.com.
Sample test case
import org.testng.annotations.Test;
public class TestClassExample {
@Test
public void dragonWarriorTestMethod() {
System.err.println("Dragon Warrior");
}
@Test
public void shifuTestMethod() {
System.err.println("Master Shifu");
}
}Sample method selector
import java.util.List;
import org.testng.IMethodSelector;
import org.testng.IMethodSelectorContext;
import org.testng.ITestNGMethod;
public class SampleMethodSelector implements IMethodSelector {
@Override
public boolean includeMethod(IMethodSelectorContext context, ITestNGMethod method,
boolean isTestMethod) {
boolean select = method.getMethodName().startsWith("dragonWarrior");
try {
return isTestMethod && select;
} finally {
//Don't evaluate any other method selector (TestNG adds a default one viz., XmlMethodSelector)
context.setStopped(true);
}
}
@Override
public void setTestMethods(List<ITestNGMethod> testMethods) {
}
}Sample suite xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="609_suite">
<test thread-count="5" name="609_test" verbose="2">
<method-selectors>
<method-selector>
<selector-class name="com.example.selectors.SampleMethodSelector"/>
</method-selector>
</method-selectors>
<classes>
<class name="com.example.selectors.TestClassExample"/>
</classes>
</test>
</suite>