1 package test.testng195; 2 3 import org.testng.IResultMap; 4 import org.testng.ITestContext; 5 import org.testng.annotations.AfterMethod; 6 import org.testng.annotations.BeforeClass; 7 import org.testng.annotations.Test; 8 9 import java.lang.reflect.Method; 10 11 public class AfterMethodSampleTest { 12 static boolean m_success; 13 14 @Test pass()15 public void pass() { 16 } 17 18 @BeforeClass init()19 public void init() { 20 m_success = false; 21 } 22 23 @AfterMethod afterMethod(ITestContext c, Method m)24 public void afterMethod(ITestContext c, Method m) { 25 IResultMap map = c.getPassedTests(); 26 m_success = map.size() == 1; 27 } 28 } 29