public void run(File testSuite) throws SpecificationException, DeploymentException, ConfigurationException { TestSuite suite= loadTestSuite(testSuite); suite.addResultListener(this); try { suite.setUp(); } catch (DeploymentException e) { try { suite.shutDown(); } catch (DeploymentException e2) {} throw e; } outputPlain("START", suite); suite.run(); suite.removeResultListener(this); outputPlain("END", suite); String result= "Test Run Completed. " + fRuns + " " + getPluralOf(fRuns, "run") + " (" + fFailures + " " + getPluralOf(fFailures, "failure") + ", " + fErrors + " " + getPluralOf(fErrors, "error") + ") \n"; outputPlain(result); System.out.println(result); outputXML(suite); closeOutputs(); suite.shutDown(); }
/** * Filters this test suite to only run the test case with the specified * name. * * Convenience method for {@link #setFilter(List)}. * * @param testCaseName * @throws TestCaseNotFoundException * If a test case with that name was not found. */ public void setFilter(String testCaseName) throws TestCaseNotFoundException { List<String> tempList = new ArrayList<String>(); tempList.add(testCaseName); setFilter(tempList); }
/** * Filters this test suite to only run the test cases with the names * specified in the list (in that order). * * @see #setFilter(String) * @param testCaseNames * @throws TestCaseNotFoundException * If one of the test cases does not exist. */ public void setFilter(List<String> testCaseNames) throws TestCaseNotFoundException { List<TestCase> filtered = new ArrayList<TestCase>(); for (String name : testCaseNames) { addTestCaseToFilter(filtered, name); } fTestCaseFilter = filtered; }
if (!suite.hasTestCase(testCaseName)) { abort(String .format(Messages suite.setUp(); } catch (DeploymentException e) { try { suite.shutDown(); } catch (DeploymentException e1) { screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_PROGRESS_RUNNING_TEST_CASES")); //$NON-NLS-1$ suite.addResultListener(this); if (testCaseNames.size() > 0) { try { suite.setFilter(testCaseNames); } catch (TestCaseNotFoundException e1) { suite.run(); suite.removeResultListener(this); screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_PROGRESS_TESTCASES_FINISHED")); //$NON-NLS-1$ suite.shutDown(); } catch (DeploymentException e) { abort(Messages.getString("BPELUnitCommandLineRunner.MSG_ERROR_UNDEPLOY"), e); //$NON-NLS-1$
/** * Creates a new Velocity context that extends the VelocityContext of the * test suite with information about this test case. To keep test cases * isolated, the context does not wrap the test suite context, but clones * and extends it. To reduce overhead, the test suite context is cached so * it is only produced the first time. * * @return VelocityContext with information about the test suite and test * case. * @throws DataSourceException * */ public Context createVelocityContext() throws DataSourceException { if (fTestSuiteVelocityContext == null) { fTestSuiteVelocityContext = getSuite().createVelocityContext(); } Context ctx = CLONER.deepClone(fTestSuiteVelocityContext); ctx.put("testCaseName", getRawName()); if (fDataSource != null) { DataSourceUtil.initializeContext(ctx, fDataSource, fRowIndex); } if (fSetUpVelocityScript != null) { StringWriter sW = new StringWriter(); Velocity.evaluate(ctx, sW, "setUpTestCase", fSetUpVelocityScript); } return ctx; }
private void createTestCase(String testDirectory, XMLTestSuiteDocument xmlTestSuiteDocument, XMLTestSuite xmlTestSuite, Map<String, Partner> suitePartners, Map<String, HumanPartner> suiteHumanPartners, Partner suiteClient, TestSuite suite, int currentNumber, XMLTestCase xmlTestCase) throws SpecificationException { String xmlTestCaseName = getTestCaseName(currentNumber, xmlTestCase); boolean isVary = xmlTestCase.getVary(); int rounds = computeNumberOfRounds(xmlTestSuiteDocument, isVary); fLogger.info("Varying: " + isVary + " (Rounds: " + rounds + ")"); IDataSource dataSource = readDataSource(testDirectory, xmlTestSuite, xmlTestCase); final int nRows = getNumberOfRows(dataSource); final int nRounds = getNumberOfRounds(isVary, rounds); for (int iRow = 0; iRow < nRows; ++iRow) { for (int iRound = 0; iRound < nRounds; iRound++) { String currentTestCaseName = getHumanReadableTestCaseName( xmlTestCaseName, rounds, dataSource, iRow, iRound); if (!xmlTestCase.getAbstract()) { TestCase test = createTestCase(suitePartners, suiteHumanPartners, suiteClient, suite, xmlTestCase, currentTestCaseName, iRound, testDirectory); test.setDataSource(dataSource); test.setRowIndex(iRow); suite.addTestCase(test); } } } }
TestSuite suite = new TestSuite(xmlSuiteName, suiteBaseURL, processUnderTest);