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