1 package test; 2 3 import org.testng.annotations.AfterTest; 4 import org.testng.annotations.BeforeClass; 5 import org.testng.annotations.Test; 6 7 public class ClassConfigurations { 8 9 static int beforeCount = 0; 10 static int afterCount = 0; 11 12 @BeforeClass beforeTestClass()13 public void beforeTestClass() { 14 ++beforeCount; 15 // System.out.println("@@@@@@ beforeTestClass has been called " + beforeCount + " time(s)"); 16 } 17 18 @AfterTest afterTest()19 public void afterTest() { 20 beforeCount = 0; 21 afterCount = 0; 22 } 23 24 @AfterTest afterTestClass()25 public void afterTestClass() { 26 ++afterCount; 27 // System.out.println("@@@@@@@ afterTestClass has been called " + afterCount + " time(s)"); 28 } 29 30 @Test testOne()31 public void testOne() { 32 // System.out.println("testOne"); 33 assert beforeCount == 1; 34 assert afterCount == 0; 35 } 36 37 @Test testTwo()38 public void testTwo() { 39 // System.out.println("testTwo"); 40 assert beforeCount == 1; 41 assert afterCount == 0; 42 } 43 44 @Test testThree()45 public void testThree() { 46 // System.out.println("testThree"); 47 assert beforeCount == 1; 48 assert afterCount == 0; 49 } 50 }