This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package selenium; | |
import java.lang.reflect.Constructor; | |
import java.lang.reflect.Method; | |
import org.testng.IAnnotationTransformer; | |
import org.testng.annotations.ITestAnnotation; | |
public class MyListener implements IAnnotationTransformer { | |
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) { | |
if(testMethod.getName().equals("method3")){ | |
annotation.setPriority(2); | |
annotation.setEnabled(false); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package selenium; | |
import org.testng.annotations.Listeners; | |
import org.testng.annotations.Test; | |
@Listeners(selenium.MyListener.class) | |
public class SeleniumExample { | |
@Test(testName="Method1", priority=2) | |
public void method1(){ | |
System.out.println("Method1"); | |
} | |
@Test(priority=1) | |
public void method2(){ | |
System.out.println("Method2"); | |
} | |
@Test(testName="Method3", priority=0) | |
public void method3(){ | |
System.out.println("Method3"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> | |
<suite name="Suite" parallel="none"> | |
<listeners> | |
<listener class-name="selenium.AnnotationTransformer" /> | |
</listeners> | |
<test name="Test"> | |
<classes> | |
<class name="selenium.SeleniumExample" /> | |
</classes> | |
</test> <!-- Test --> | |
</suite> <!-- Suite --> |
No comments:
Post a Comment