1 package test.hook; 2 3 import org.testng.Assert; 4 import org.testng.annotations.BeforeClass; 5 import org.testng.annotations.BeforeMethod; 6 import org.testng.annotations.BeforeSuite; 7 import org.testng.annotations.Listeners; 8 import org.testng.annotations.Test; 9 10 import java.lang.reflect.Method; 11 12 @Listeners(ConfigurableListener.class) 13 public class ConfigurableSuccessWithListenerTest { 14 static boolean m_bm = false; 15 static boolean m_bc = false; 16 static boolean m_bt; 17 static boolean m_bs; 18 19 @BeforeSuite bs()20 public void bs() { 21 m_bs = true; 22 } 23 24 @BeforeMethod bt()25 public void bt() { 26 m_bt = true; 27 } 28 29 @BeforeMethod bm(Method m)30 public void bm(Method m) { 31 m_bm = true; 32 } 33 34 @BeforeClass bc()35 public void bc() { 36 m_bc = true; 37 } 38 39 @Test hookWasRun()40 public void hookWasRun() { 41 Assert.assertEquals(ConfigurableListener.m_hookCount, 2); 42 Assert.assertTrue(m_bc); 43 Assert.assertTrue(m_bm); 44 } 45 } 46