private XmlSuite getXmlSuite() { // we cannot use singletonLists here as testNG later // modifies lists stored in XmlSuite ... zonk XmlSuite testSuite = new XmlSuite(); testSuite.setName("tempto-tests"); testSuite.setFileName("tempto-tests"); XmlTest test = new XmlTest(testSuite); test.setName("all"); XmlPackage testPackage = new XmlPackage(options.getTestsPackage()); List<XmlPackage> testPackages = newArrayList(testPackage); test.setPackages(testPackages); XmlClass conventionBasedTestsClass = new XmlClass("io.prestodb.tempto.internal.convention.ConventionBasedTestFactory"); List<XmlClass> classes = newArrayList(conventionBasedTestsClass); test.setClasses(classes); test.setParallel(XmlSuite.ParallelMode.METHODS); return testSuite; }
public static List<XmlPackage> getPackages() { List<XmlPackage> allPackages = new ArrayList<>(); XmlPackage eachPackage = new XmlPackage(); eachPackage.setName("output"); allPackages.add(eachPackage); return allPackages; }
private void init(IConfiguration configuration, ISuite suite, XmlTest test, String outputDirectory, IAnnotationFinder annotationFinder, boolean skipFailedInvocationCounts, Collection<IInvokedMethodListener> invokedMethodListeners, List<IClassListener> classListeners) { m_configuration = configuration; m_xmlTest= test; m_suite = suite; m_testName = test.getName(); m_host = suite.getHost(); m_testClassesFromXml= test.getXmlClasses(); m_skipFailedInvocationCounts = skipFailedInvocationCounts; setVerbose(test.getVerbose()); boolean preserveOrder = test.getPreserveOrder(); m_methodInterceptors = new ArrayList<IMethodInterceptor>(); builtinInterceptor = preserveOrder ? new PreserveOrderMethodInterceptor() : new InstanceOrderingMethodInterceptor(); m_packageNamesFromXml= test.getXmlPackages(); if(null != m_packageNamesFromXml) { for(XmlPackage xp: m_packageNamesFromXml) { m_testClassesFromXml.addAll(xp.getXmlClasses()); } } m_annotationFinder= annotationFinder; m_invokedMethodListeners = invokedMethodListeners; m_classListeners.clear(); for (IClassListener classListener : classListeners) { m_classListeners.put(classListener.getClass(), classListener); } m_invoker = new Invoker(m_configuration, this, this, m_suite.getSuiteState(), m_skipFailedInvocationCounts, invokedMethodListeners, classListeners); if (test.getParallel() != null) { log(3, "Running the tests in '" + test.getName() + "' with parallel mode:" + test.getParallel()); } setOutputDirectory(outputDirectory); // Finish our initialization init(); }
/** * Run suites. * * @throws ClassNotFoundException * @throws IOException * @throws ParseException */ @TestProjectLoggable (level=ATELogLevel.INFO) public void runSuites() throws ClassNotFoundException, ParseException, IOException { final TestProjectListener tla = new TestProjectListener(this); final TestCaseResultModifier repeatStepResultModifier = new TestCaseResultModifier(); testng.addListener(tla); testng.addListener(repeatStepResultModifier); ATEXMLReporter rng = new ATEXMLReporter(); rng.setStackTraceOutputMethod(XMLReporterConfig.STACKTRACE_NONE); testng.addListener(rng); CaseRunnerGenerator crg = new CaseRunnerGenerator(this.getSuiteList()); crg.createCaseRunners(); if (0 == crg.loadCaseRunnerClasses()) { throw new ParseException("case runner generator error"); } final List<XmlPackage> packages = new ArrayList<XmlPackage>(); for (TestSuite tempSuite : getSuiteList()) { XmlPackage xmlpackage = new XmlPackage(); xmlpackage.setName(crg.getBasePackageName() + "." + tempSuite.getSuiteName()); packages.add(xmlpackage); } List<XmlSuite> xmlSuites = new ArrayList<XmlSuite>(); XmlSuite xmlProject = new XmlSuite(); XmlTest test = new XmlTest(xmlProject); test.setPackages(packages); xmlSuites.add(xmlProject); if (xmlSuites.isEmpty()) { throw new IllegalStateException("xmlsuites are not populated."); } else { testng.setXmlSuites(xmlSuites); testng.run(); } }