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: * beforeGroups test: make sure that if before methods are scattered on
12: * more than one class, they are still taken into account
13: *
14: * @author cbeust
15: * @date Mar 3, 2006
16: */
17: public class ConfigurationGroups3SampleTest extends Base3 {
18: private boolean m_before = false;
19: static private boolean m_f1 = false;
20:
21: @BeforeGroups("cg34-1")
22: public void before1() {
23: Assert.assertFalse(m_before);
24: Assert.assertFalse(m_f1);
25: m_before = true;
26: log("before1");
27: }
28:
29: @Test(groups="cg34-a")
30: public void fa() {
31: log("fa");
32: }
33:
34: @Test(groups="cg34-1")
35: public void f1() {
36: Assert.assertTrue(m_before);
37: Assert.assertTrue(Base3.getBefore());
38: m_f1 = true;
39: log("f1");
40: }
41:
42: private List<String> m_list = new ArrayList<String>();
43:
44: @Test(dependsOnGroups={"cg34-a","cg34-1"})
45: public void verify() {
46: Assert.assertTrue(m_before);
47: Assert.assertTrue(Base3.getBefore());
48: Assert.assertTrue(m_f1);
49: }
50:
51: private void log(String s) {
52: m_list.add(s);
53: ppp(s);
54: }
55:
56: private void ppp(String s) {
57: if (false) {
58: System.out.println("[ConfigurationGroups3SampleTest] " + s);
59: }
60: }
61:
62: public static boolean getF1() {
63: return m_f1;
64: }
65:
66: }
|