publicclass TestngAnnotation {
// test case 1
@Test
publicvoidtestCase1() {
System.out.println("in test case 1");
}
// test case 2
@Test
publicvoidtestCase2() {
System.out.println("in test case 2");
}
@BeforeMethod
publicvoidbeforeMethod() {
System.out.println("in beforeMethod");
}
@AfterMethod
publicvoidafterMethod() {
System.out.println("in afterMethod");
}
@BeforeClass
publicvoidbeforeClass() {
System.out.println("in beforeClass");
}
@AfterClass
publicvoidafterClass() {
System.out.println("in afterClass");
}
@BeforeTest
publicvoidbeforeTest() {
System.out.println("in beforeTest");
}
@AfterTest
publicvoidafterTest() {
System.out.println("in afterTest");
}
@BeforeSuite
publicvoidbeforeSuite() {
System.out.println("in beforeSuite");
}
@AfterSuite
publicvoidafterSuite() {
System.out.println("in afterSuite");
}
}
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
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
其执行顺序为
in beforeSuite
in beforeTest
in beforeClass
in beforeMethod
in test case1in afterMethod
in beforeMethod
in test case2in afterMethod
in afterClass
in afterTest
in afterSuite