package com.course.testng.groups; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class GroupsOnMethod { @Test(groups = "server") public void test1(){ System.out.println("这是server 1 测试......."); } @Test(groups = "server") public void test2(){ System.out.println("这是server 2测试............."); } @Test public void Test3 () { System.out.println ( "test which is the client 1 ..........." ); } @BeforeGroups ( "Server" ) public void Server1 ( ) { System.out.println ( "server which is performed before the test -----------------------" ); } @AfterGroups ( "server" ) public void Server2 () { System.out.println ( "this is performed after execution server *********** test" ); } }