I have testng.xml suppose,
<suite name="TestSuite" parallel="false"> <test name="smoke" preserve-order="true" verbose="2"> <groups> <run> <include name="smoke"/> </run> </groups> <classes> <class name="com.testClass1"/> <class name="com.testClass2"/> </classes> </test> </suite> This may contain more classes close to 10-15, this is my generic testng.xml, from different set of testdata, what I want is to skip com.testClass1 classs, for particular case, and rest of test should execute.
I tried with implementing my class using, IAnnotationTransformer listener of testng.
the code snippet is,
public class SkipTestClass implements IAnnotationTransformer{ private SessionProfile profile=null; public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) { if (testMethod != null) { Test test = testMethod.getDeclaringClass().getAnnotation(Test.class); if (test != null && !test.enabled() && testMethod.getDeclaringClass().getClass().getName().equalsIgnoreCase("com.testClass1")) { annotation.setEnabled(false); } } } } and calling this listener at Test Class level,as
@Listeners(com.SkipTestClass.class),
Expected Result: I am assuming, only this class com.testClass1 & it's testmethods & beforeclass & afterclass methods should skip and rest of suite should execute.
Actual Result: Whole suite is getting skipped.
Any Help, please?