use of org.testng.xml.XmlTest in project druid by druid-io.
the class RemoteTestNG method buildTestRunnerFactory.
/**
* Override by the plugin if you need to configure differently the <code>TestRunner</code>
* (usually this is needed if different listeners/reporters are needed).
* <b>Note</b>: you don't need to worry about the wiring listener, because it is added
* automatically.
*/
protected ITestRunnerFactory buildTestRunnerFactory() {
//################### PATCH STARTS
if (System.getProperty("testrunfactory") != null) {
m_customTestRunnerFactory = (ITestRunnerFactory) ClassHelper.newInstance(ClassHelper.fileToClass(System.getProperty("testrunfactory")));
//################## PATCH ENDS
} else if (null == m_customTestRunnerFactory) {
m_customTestRunnerFactory = new ITestRunnerFactory() {
@Override
public TestRunner newTestRunner(ISuite suite, XmlTest xmlTest, List<IInvokedMethodListener> listeners) {
TestRunner runner = new TestRunner(getConfiguration(), suite, xmlTest, false, /*skipFailedInvocationCounts */
listeners);
if (m_useDefaultListeners) {
runner.addListener(new TestHTMLReporter());
runner.addListener(new JUnitXMLReporter());
}
return runner;
}
};
}
return m_customTestRunnerFactory;
}
use of org.testng.xml.XmlTest in project druid by druid-io.
the class TestNG method createCommandLineSuitesForMethods.
/**
* @param commandLineMethods a string with the form "com.example.Foo.f1,com.example.Bar.f2"
*
* @return a list of XmlSuite objects that represent the list of classes and methods passed
* in parameter.
*/
private List<XmlSuite> createCommandLineSuitesForMethods(List<String> commandLineMethods) {
//
// Create the <classes> tag
//
Set<Class> classes = Sets.newHashSet();
for (String m : commandLineMethods) {
Class c = ClassHelper.forName(splitMethod(m)[0]);
if (c != null) {
classes.add(c);
}
}
List<XmlSuite> result = createCommandLineSuitesForClasses(classes.toArray(new Class[0]));
//
// Add the method tags
//
List<XmlClass> xmlClasses = Lists.newArrayList();
for (XmlSuite s : result) {
for (XmlTest t : s.getTests()) {
xmlClasses.addAll(t.getClasses());
}
}
for (XmlClass xc : xmlClasses) {
for (String m : commandLineMethods) {
String[] split = splitMethod(m);
String className = split[0];
if (xc.getName().equals(className)) {
XmlInclude includedMethod = new XmlInclude(split[1]);
xc.getIncludedMethods().add(includedMethod);
}
}
}
return result;
}
use of org.testng.xml.XmlTest in project druid by druid-io.
the class TestNG method extractTestNames.
/**
* 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) {
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;
}
}
use of org.testng.xml.XmlTest in project druid by druid-io.
the class TestNG method initializeCommandLineSuitesGroups.
private void initializeCommandLineSuitesGroups() {
// If groups were specified on the command line, they should override groups
// specified in the XML file
boolean hasIncludedGroups = null != m_includedGroups && m_includedGroups.length > 0;
boolean hasExcludedGroups = null != m_excludedGroups && m_excludedGroups.length > 0;
List<XmlSuite> suites = m_cmdlineSuites != null ? m_cmdlineSuites : m_suites;
if (hasIncludedGroups || hasExcludedGroups) {
for (XmlSuite s : suites) {
//set on each test, instead of just the first one of the suite
for (XmlTest t : s.getTests()) {
if (hasIncludedGroups) {
t.setIncludedGroups(Arrays.asList(m_includedGroups));
}
if (hasExcludedGroups) {
t.setExcludedGroups(Arrays.asList(m_excludedGroups));
}
}
}
}
}
use of org.testng.xml.XmlTest in project buck by facebook.
the class TestNGRunner method createXmlSuite.
private XmlSuite createXmlSuite(Class<?> c) {
XmlSuite xmlSuite = new XmlSuite();
xmlSuite.setName("TmpSuite");
xmlSuite.setTimeOut(String.valueOf(defaultTestTimeoutMillis));
XmlTest xmlTest = new XmlTest(xmlSuite);
xmlTest.setName("TmpTest");
xmlTest.setXmlClasses(Collections.singletonList(new XmlClass(c)));
return xmlSuite;
}
Aggregations