测试代码:
package com.soos.apps.selenium.apply; import org.testng.annotations.*; @Test public class TestDemo { @BeforeMethod public void beforeMethod(){ System.out.println("beforeMethod"); } @AfterMethod public void afterMethod(){ System.out.println("afterMethod"); } @BeforeClass public void beforeClass(){ System.out.println("beforeClass"); } @AfterClass public void afterClass(){ System.out.println("afterClass"); } @BeforeGroups(groups = {"test"}) public void beforeGroup(){ System.out.println("beforeGroup"); } @AfterGroups(groups = {"test"}) public void afterGroup(){ System.out.println("afterGroup"); } @BeforeTest public void beforeTest(){ System.out.println("beforeTest"); } @AfterTest public void afterTest(){ System.out.println("afterTest"); } @Test(groups = {"test"}) public void test1(){ System.out.println("test1"); } @Test(groups = {"test"}) public void test2(){ System.out.println("test2"); } @Test(groups = {"test1"}) public void test3(){ System.out.println("test3"); } @Test(groups = {"test1"}) public void test4(){ System.out.println("test4"); } }
运行结果:
得出结果:
标签:顺序,void,System,TestNG,groups,println,注解,public,out From: https://www.cnblogs.com/0099-ymsml/p/17815090.html