01: package test.dependent;
02:
03: import org.testng.TestNG;
04:
05: /**
06: * This class exercises dependent methods
07: *
08: * @author Cedric Beust, Aug 19, 2004
09: *
10: */
11: public class SampleDependentMethods {
12: private boolean m_oneA = false;
13: private boolean m_oneB = false;
14: private boolean m_secondA = false;
15: private boolean m_thirdA = false;
16:
17: /**
18: * @testng.test
19: */
20: public void oneA() {
21: // ppp("oneA");
22: assert !m_secondA : "secondA shouldn't have been run yet";
23: m_oneA = true;
24: }
25:
26: /**
27: * @testng.test
28: */
29: public void canBeRunAnytime() {
30:
31: }
32:
33: /**
34: * @testng.test dependsOnMethods = "oneA oneB";
35: */
36: public void secondA() {
37: // ppp("secondA");
38: assert m_oneA : "oneA wasn't run";
39: assert m_oneB : "oneB wasn't run";
40: assert !m_secondA : "secondA shouldn't have been run yet";
41: m_secondA = true;
42: }
43:
44: /**
45: * @testng.test dependsOnMethods = "secondA";
46: */
47: public void thirdA() {
48: // ppp("thirdA");
49: assert m_oneA : "oneA wasn't run";
50: assert m_oneB : "oneB wasn't run";
51: assert m_secondA : "secondA wasn't run";
52: assert !m_thirdA : "thirdA shouldn't have been run yet";
53: m_thirdA = true;
54: }
55:
56: /**
57: * @testng.test
58: */
59: public void oneB() {
60: // ppp("oneB");
61: assert !m_secondA : "secondA shouldn't have been run yet";
62: m_oneB = true;
63: }
64:
65: /**
66: * @testng.after-class
67: */
68: public void tearDown() {
69: assert m_oneA : "oneA wasn't run";
70: assert m_oneB : "oneB wasn't run";
71: assert m_secondA : "secondA wasn't run";
72: assert m_thirdA : "thirdA wasn't run";
73: }
74:
75: public static void ppp(String s) {
76: System.out.println("[SampleDependentMethods] " + s);
77: }
78: }
|