01: package test.configuration;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import org.testng.Assert;
07: import org.testng.annotations.BeforeGroups;
08: import org.testng.annotations.Test;
09:
10: /**
11: * Simple beforeGroups test: 1 before method and 2 test method
12: *
13: * @author cbeust
14: * @date Mar 3, 2006
15: */
16: public class ConfigurationGroups1SampleTest {
17: private boolean m_before = false;
18: private boolean m_f1 = false;
19:
20: @BeforeGroups("cg1-1")
21: public void before1() {
22: Assert.assertFalse(m_before);
23: Assert.assertFalse(m_f1);
24: m_before = true;
25: log("before1");
26: }
27:
28: @Test(groups="cg1-a")
29: public void fa() {
30: log("fa");
31: }
32:
33: @Test(groups="cg1-1")
34: public void f1() {
35: Assert.assertTrue(m_before);
36: m_f1 = true;
37: log("f1");
38: }
39:
40: private List<String> m_list = new ArrayList<String>();
41:
42: @Test(dependsOnGroups={"cg1-a","cg1-1"})
43: public void verify() {
44: Assert.assertTrue(m_before);
45: Assert.assertTrue(m_f1);
46: }
47:
48: private void log(String s) {
49: m_list.add(s);
50: ppp(s);
51: }
52:
53: private void ppp(String s) {
54: if (false) {
55: System.out.println("[ConfigurationGroups1SampleTest] " + s);
56: }
57: }
58:
59: }
|