1package test.testnames;
2
3import org.testng.Assert;
4import org.testng.TestListenerAdapter;
5import org.testng.TestNG;
6import org.testng.annotations.Test;
7import test.SimpleBaseTest;
8
9import java.util.Collections;
10
11public class TestNamesTest extends SimpleBaseTest {
12
13    @Test
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