1 package test.testng249; 2 3 import org.testng.Assert; 4 import org.testng.TestListenerAdapter; 5 import org.testng.TestNG; 6 import org.testng.annotations.Test; 7 import org.testng.xml.XmlClass; 8 import org.testng.xml.XmlInclude; 9 import org.testng.xml.XmlSuite; 10 import org.testng.xml.XmlTest; 11 12 import test.SimpleBaseTest; 13 14 import java.util.Arrays; 15 16 public class VerifyTest extends SimpleBaseTest { 17 18 @Test verify()19 public void verify() { 20 XmlSuite suite = new XmlSuite(); 21 suite.setName("Suite"); 22 23 XmlTest test = new XmlTest(suite); 24 test.setName("Test"); 25 XmlClass c1 = new XmlClass(B.class); 26 c1.setIncludedMethods(Arrays.asList(new XmlInclude[] { new XmlInclude("b")})); 27 XmlClass c2 = new XmlClass(Base.class); 28 c2.setIncludedMethods(Arrays.asList(new XmlInclude[] { new XmlInclude("b")})); 29 test.setXmlClasses(Arrays.asList(new XmlClass[] { c1, c2 })); 30 31 TestNG tng = new TestNG(); 32 tng.setVerbose(0); 33 tng.setXmlSuites(Arrays.asList(new XmlSuite[] { suite })); 34 TestListenerAdapter tla = new TestListenerAdapter(); 35 tng.addListener(tla); 36 tng.run(); 37 38 Assert.assertEquals(tla.getPassedTests().size(), 2); 39 } 40 } 41