1 package test.dependent; 2 3 import org.testng.annotations.AfterClass; 4 import org.testng.annotations.Test; 5 6 7 /** 8 * This class exercises dependent methods 9 * 10 * @author Cedric Beust, Aug 19, 2004 11 * 12 */ 13 public class SampleDependentMethods { 14 private boolean m_oneA = false; 15 private boolean m_oneB = false; 16 private boolean m_secondA = false; 17 private boolean m_thirdA = false; 18 19 @Test oneA()20 public void oneA() { 21 // ppp("oneA"); 22 // assert false : "TEMPORARY FAILURE"; 23 assert ! m_secondA : "secondA shouldn't have been run yet"; 24 m_oneA = true; 25 } 26 27 @Test canBeRunAnytime()28 public void canBeRunAnytime() { 29 30 } 31 32 @Test(dependsOnMethods= { "oneA", "oneB" }) secondA()33 public void secondA() { 34 // ppp("secondA"); 35 assert m_oneA : "oneA wasn't run"; 36 assert m_oneB : "oneB wasn't run"; 37 assert ! m_secondA : "secondA shouldn't have been run yet"; 38 m_secondA = true; 39 40 } 41 42 @Test(dependsOnMethods= { "secondA" }) thirdA()43 public void thirdA() { 44 // ppp("thirdA"); 45 assert m_oneA : "oneA wasn't run"; 46 assert m_oneB : "oneB wasn't run"; 47 assert m_secondA : "secondA wasn't run"; 48 assert ! m_thirdA : "thirdA shouldn't have been run yet"; 49 m_thirdA = true; 50 51 } 52 53 @Test oneB()54 public void oneB() { 55 // ppp("oneB"); 56 assert ! m_secondA : "secondA shouldn't have been run yet"; 57 m_oneB = true; 58 } 59 60 @AfterClass tearDown()61 public void tearDown() { 62 assert m_oneA : "oneA wasn't run"; 63 assert m_oneB : "oneB wasn't run"; 64 assert m_secondA : "secondA wasn't run"; 65 assert m_thirdA : "thirdA wasn't run"; 66 } 67 ppp(String s)68 public static void ppp(String s) { 69 System.out.println("[SampleDependentMethods] " + s); 70 } 71 }