01: package test.configuration;
02:
03: import java.util.ArrayList;
04: import java.util.Arrays;
05: import java.util.List;
06:
07: import org.testng.Assert;
08: import org.testng.annotations.AfterMethod;
09: import org.testng.annotations.Test;
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<String>();
21:
22: @Test
23: public void dummy() {
24: m_log.add("should not be invoked");
25: }
26:
27: @Test(groups={"A"})
28: public void testSomething() {
29: m_log.add("1");
30: }
31:
32: @Test(groups={"A"})
33: public void testSomethingMore() {
34: m_log.add("1");
35: }
36:
37: @AfterMethod
38: private void cleanUpDummy() {
39: m_log.add("should not be invoked");
40: }
41:
42: @AfterMethod(groups="A")
43: private void cleanUpA() {
44: m_log.add("a");
45: }
46:
47: @Test(dependsOnGroups="A",groups="B")
48: public void verify() {
49: Assert.assertEquals(Arrays.asList(new String[] { "1", "a", "1",
50: "a" }), m_log);
51: }
52:
53: }
|