1 package test.configuration; 2 3 import org.testng.Assert; 4 import org.testng.annotations.AfterGroups; 5 import org.testng.annotations.BeforeGroups; 6 import org.testng.annotations.Test; 7 8 import java.util.ArrayList; 9 import java.util.Arrays; 10 import java.util.List; 11 12 public class ConfigurationGroups7SampleTest { 13 private List<String> m_log = new ArrayList<>(); 14 15 @BeforeGroups({"A"}) initA()16 private void initA() { 17 m_log.add("1"); 18 } 19 20 @Test(groups = {"A"}) testSomething()21 public void testSomething() { 22 m_log.add("2"); 23 } 24 25 @Test(groups = {"A"}) testSomethingMore()26 public void testSomethingMore() { 27 m_log.add("2"); 28 } 29 30 @AfterGroups({"A"}) cleanUpA()31 private void cleanUpA() { 32 m_log.add("3"); 33 } 34 35 @Test(dependsOnGroups = "A") verify()36 public void verify() { 37 Assert.assertEquals(Arrays.asList(new String[] { "1", "2", "2", "3"}), m_log); 38 } 39 40 } 41