01: package test.configuration;
02:
03: import org.testng.Assert;
04: import org.testng.annotations.AfterGroups;
05: import org.testng.annotations.Test;
06:
07: /**
08: * Simple afterGroups test
09: *
10: * @author cbeust
11: * @date Mar 7, 2006
12: */
13: public class ConfigurationGroups4SampleTest {
14:
15: private boolean m_after = false;
16: private boolean m_run = false;
17:
18: @Test
19: public void f() {
20: log("f");
21: }
22:
23: @Test(groups="cg4-1")
24: public void run() {
25: log("run");
26: Assert.assertFalse(m_after);
27: m_run = true;
28: m_run = true;
29: }
30:
31: @AfterGroups("cg4-1")
32: public void after1() {
33: log("after1");
34: Assert.assertTrue(m_run);
35: Assert.assertFalse(m_after);
36: m_after = true;
37: }
38:
39: @Test(dependsOnGroups="cg4-1")
40: public void verify() {
41: log("verify");
42: Assert.assertTrue(m_run, "run() wasn't run");
43: Assert.assertTrue(m_after, "after1() wasn't run");
44: }
45:
46: private void log(String string) {
47: ppp(string);
48: }
49:
50: private void ppp(String s) {
51: if (false) {
52: System.out.println("[ConfigurationGroups4SampleTest] " + s);
53: }
54: }
55:
56: }
|