1 package test.dependent; 2 3 import org.testng.Assert; 4 import org.testng.annotations.BeforeMethod; 5 import org.testng.annotations.Test; 6 7 8 /** 9 * This class/interface 10 */ 11 public class DependsOnProtectedMethodTest { 12 private boolean m_before1 = false; 13 private boolean m_before2 = false; 14 15 @BeforeMethod(dependsOnMethods = { "before2" }) before()16 protected void before() { 17 m_before1 = true; 18 } 19 20 @BeforeMethod before2()21 protected void before2() { 22 m_before2 = true; 23 } 24 25 @Test verifyBeforeInvocations()26 public void verifyBeforeInvocations() { 27 Assert.assertTrue(m_before1 && m_before2, "Protected dependent @BeforeMethods should have been invoked"); 28 } 29 } 30