1 package test.jason; 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 MainTest extends SimpleBaseTest { 16 17 @Test afterClassShouldRun()18 public void afterClassShouldRun() { 19 XmlSuite s = createXmlSuite("S"); 20 XmlTest t = createXmlTest(s, "T", Main.class.getName()); 21 XmlClass c = t.getXmlClasses().get(0); 22 c.getIncludedMethods().add(new XmlInclude("test1")); 23 t.setPreserveOrder("true"); 24 TestNG tng = create(); 25 tng.setXmlSuites(Arrays.asList(new XmlSuite[] { s })); 26 Main.m_passed = false; 27 tng.run(); 28 Assert.assertTrue(Main.m_passed); 29 } 30 }