Code with Finding: |
class TestNG { /** * If the XmlSuite contains at least one test named as testNames, return * an XmlSuite that's made only of these tests, otherwise, return the * original suite. */ private static XmlSuite extractTestNames(XmlSuite s, List<String> testNames) { extractTestNamesFromChildSuites(s, testNames);
List<XmlTest> tests = Lists.newArrayList(); for (XmlTest xt : s.getTests()) { for (String tn : testNames) { if (xt.getName().equals(tn)) { tests.add(xt); } } }
if (tests.size() == 0) { return s; } else { XmlSuite result = (XmlSuite) s.clone(); result.getTests().clear(); result.getTests().addAll(tests); return result; } }
}
|