1 package test.verify; 2 3 import org.testng.ITestNGListener; 4 import org.testng.ITestNGListenerFactory; 5 import org.testng.annotations.Listeners; 6 import org.testng.annotations.Test; 7 8 /** 9 * Illustrate the implementation of a @Verify/@Verifier test. 10 * 11 * One method should be annotated with @Verifier and then each test method 12 * annotated with @Verify will be followed with a call to the @Verifier 13 * method. 14 */ 15 @Listeners(VerifyTestListener.class) 16 public class Verify2SampleTest implements ITestNGListenerFactory { 17 Verify2SampleTest()18 public Verify2SampleTest() {} 19 20 @Verify 21 @Test f1()22 public void f1() { 23 log("f1"); 24 } 25 26 @Verify 27 @Test f2()28 public void f2() { 29 log("f2"); 30 } 31 32 @Verifier 33 @Test verify()34 public void verify() { 35 log("Verifying"); 36 } 37 log(String string)38 private void log(String string) { 39 if (false) { 40 System.out.println(hashCode() + " " + string); 41 } 42 } 43 44 @Override createListener(Class<? extends ITestNGListener> listenerClass)45 public ITestNGListener createListener(Class<? extends ITestNGListener> listenerClass) { 46 log("Creating a listener of type " + listenerClass); 47 return null; 48 } 49 } 50