1 package test.bug90; 2 3 import org.testng.Assert; 4 import org.testng.TestNG; 5 import org.testng.annotations.Test; 6 import org.testng.xml.XmlClass; 7 import org.testng.xml.XmlInclude; 8 import org.testng.xml.XmlSuite; 9 import org.testng.xml.XmlTest; 10 11 import test.SimpleBaseTest; 12 13 import java.util.Arrays; 14 15 public class Bug90Test extends SimpleBaseTest { 16 17 @Test(description = "Fix for https://github.com/cbeust/testng/issues/90") afterClassShouldRun()18 public void afterClassShouldRun() { 19 XmlSuite s = createXmlSuite("Bug90"); 20 XmlTest t = createXmlTest(s, "Bug90 test", Sample.class.getName()); 21 XmlClass c = t.getClasses().get(0); 22 c.setIncludedMethods(Arrays.asList(new XmlInclude("test1"))); 23 TestNG tng = create(); 24 tng.setXmlSuites(Arrays.asList(s)); 25 Sample.m_afterClassWasRun = false; 26 tng.run(); 27 28 Assert.assertTrue(Sample.m_afterClassWasRun); 29 } 30 } 31