1 package test.alwaysrun; 2 3 import org.testng.annotations.AfterClass; 4 import org.testng.annotations.BeforeClass; 5 import org.testng.annotations.Test; 6 7 public class AlwaysRunAfter1 { 8 private static boolean m_success = false; 9 10 @BeforeClass setUpShouldFail()11 public void setUpShouldFail() { 12 throw new RuntimeException("Failing in setUp"); 13 } 14 15 @AfterClass(alwaysRun = true) tearDown()16 public void tearDown() { 17 m_success = true; 18 } 19 20 // Adding this method or @Configuration will never be invoked 21 @Test dummy()22 public void dummy() { 23 24 } 25 success()26 static public boolean success() { 27 return m_success; 28 } 29 } 30