1 package test.sample; 2 3 import org.testng.annotations.AfterClass; 4 import org.testng.annotations.AfterTest; 5 import org.testng.annotations.Test; 6 7 public class Basic2 { 8 private boolean m_basic2WasRun = false; 9 private static int m_afterClass = 0; 10 11 @Test(dependsOnGroups = { "basic1" }) basic2()12 public void basic2() { 13 m_basic2WasRun = true; 14 assert Basic1.getCount() > 0 : "COUNT WAS NOT INCREMENTED"; 15 } 16 17 @AfterTest cleanUp()18 public void cleanUp() { 19 m_basic2WasRun = false; 20 m_afterClass = 0; 21 } 22 ppp(String s)23 private void ppp(String s) { 24 System.out.println("[Basic2 " 25 + Thread.currentThread().getId() + " ] " + hashCode() + " " + s); 26 } 27 28 @AfterClass checkTestAtClassLevelWasRun()29 public void checkTestAtClassLevelWasRun() { 30 m_afterClass++; 31 assert m_basic2WasRun : "Class annotated with @Test didn't have its methods run."; 32 assert 1 == m_afterClass : "After class should have been called exactly once, not " + m_afterClass; 33 } 34 }