1 package test.testnames; 2 3 import org.testng.Assert; 4 import org.testng.TestListenerAdapter; 5 import org.testng.TestNG; 6 import org.testng.annotations.Test; 7 import test.SimpleBaseTest; 8 9 import java.util.Collections; 10 11 public class TestNamesTest extends SimpleBaseTest { 12 13 @Test checkWithoutChildSuites()14 public void checkWithoutChildSuites() { 15 TestListenerAdapter tla = new TestListenerAdapter(); 16 TestNG tng = create(); 17 tng.setTestNames(Collections.singletonList("testGroup2")); 18 tng.setTestSuites(Collections.singletonList(getPathToResource("testnames/upstream-suite.xml"))); 19 tng.addListener(tla); 20 tng.run(); 21 Assert.assertEquals(tla.getFailedTests().size(), 0); 22 Assert.assertEquals(tla.getPassedTests().size(), 1); 23 Assert.assertEquals(tla.getPassedTests().get(0).getMethod().getMethodName(), "sampleOutputTest2"); 24 } 25 } 26