1 package test.configuration; 2 3 import static org.testng.Assert.assertFalse; 4 import static org.testng.Assert.assertTrue; 5 6 import org.testng.annotations.AfterSuite; 7 import org.testng.annotations.AfterTest; 8 import org.testng.annotations.BeforeSuite; 9 import org.testng.annotations.BeforeTest; 10 11 12 public class ExternalConfigurationClass { 13 public static boolean s_afterMethod; 14 public static boolean s_afterClass; 15 public static boolean s_afterTest; 16 17 @BeforeSuite beforeSuite()18 public void beforeSuite() { 19 MethodCallOrderTest.s_beforeSuite = true; 20 } 21 22 @AfterSuite cleanUp()23 public void cleanUp() { 24 s_afterMethod = false; 25 s_afterClass = false; 26 s_afterTest = false; 27 } 28 29 @BeforeTest beforeTest()30 public void beforeTest() { 31 assertTrue(MethodCallOrderTest.s_beforeSuite); 32 assertFalse(MethodCallOrderTest.s_beforeTest); 33 assertFalse(MethodCallOrderTest.s_beforeClass); 34 assertFalse(MethodCallOrderTest.s_beforeMethod); 35 36 MethodCallOrderTest.s_beforeTest = true; 37 } 38 39 @AfterTest afterTest()40 public void afterTest() { 41 assertTrue(s_afterMethod, "afterTestMethod should have been run"); 42 assertTrue(s_afterClass, "afterTestClass should have been run"); 43 assertFalse(s_afterTest, "afterTest should haven't been run"); 44 s_afterTest = true; 45 } 46 47 @AfterSuite afterSuite()48 public void afterSuite() { 49 assertTrue(s_afterMethod, "afterTestMethod should have been run"); 50 assertTrue(s_afterClass, "afterTestClass should have been run"); 51 assertTrue(s_afterTest, "afterTest should have been run"); 52 } 53 } 54