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