1 package test.configuration;
2 
3 import org.testng.Assert;
4 import org.testng.annotations.AfterMethod;
5 import org.testng.annotations.Test;
6 
7 import java.util.ArrayList;
8 import java.util.Arrays;
9 import java.util.List;
10 
11 /**
12  * Run with group "A" and "B"
13  * Make sure that only methods and configurations belonging to that group
14  * get invoked.
15  *
16  * @author cbeust
17  * @date Mar 9, 2006
18  */
19 public class ConfigurationGroups8SampleTest {
20   private List<String> m_log = new ArrayList<>();
21 
22   @Test
dummy()23   public void dummy() {
24     m_log.add("should not be invoked");
25   }
26 
27   @Test(groups = { "A" })
testSomething()28   public void testSomething() {
29     m_log.add("1");
30   }
31 
32   @Test(groups = { "A" })
testSomethingMore()33   public void testSomethingMore() {
34     m_log.add("1");
35   }
36 
37   @AfterMethod
cleanUpDummy()38   private void cleanUpDummy() {
39     m_log.add("should not be invoked");
40   }
41 
42   @AfterMethod(groups = "A")
cleanUpA()43   private void cleanUpA() {
44     m_log.add("a");
45   }
46 
47   @Test(dependsOnGroups = "A", groups = "B")
verify()48   public void verify() {
49     Assert.assertEquals(Arrays.asList(new String[] { "1", "a", "1", "a" }),
50         m_log);
51   }
52 
53 }
54