org.apache.tools.ant.taskdefs.optional.junit.JUnitTest Java Examples
The following examples show how to use
org.apache.tools.ant.taskdefs.optional.junit.JUnitTest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OneLinerFormatter.java From pxf with Apache License 2.0 | 6 votes |
@Override public void startTestSuite(JUnitTest suite) throws BuildException { if (output == null) { return; } StringBuffer sb = new StringBuffer(StringUtils.LINE_SEP); sb.append("----------------------------------------------------------"); sb.append(StringUtils.LINE_SEP); sb.append("Testsuite: "); sb.append(suite.getName()); sb.append(StringUtils.LINE_SEP); sb.append("----------------------------------------------------------"); sb.append(StringUtils.LINE_SEP); output.write(sb.toString()); output.flush(); }
Example #2
Source File: JunitFormatter.java From reladomo with Apache License 2.0 | 6 votes |
public void startTestSuite(JUnitTest suite) { failures = 0; errors = 0; tests = 0; suiteName = suite.getName(); if (suiteName.lastIndexOf('.') > 0) { suiteName = suiteName.substring(suiteName.lastIndexOf('.')+1); } suiteName += "/"+System.getProperty("mithra.xml.config"); originalOut.println("Start Suite "+ suiteName); lastMessageTime = System.currentTimeMillis(); originalOut.flush(); flush(); }
Example #3
Source File: JunitFormatter.java From gs-xsd2bean with Apache License 2.0 | 6 votes |
public void startTestSuite(JUnitTest suite) { failures = 0; errors = 0; tests = 0; suiteName = suite.getName(); if (suiteName.lastIndexOf('.') > 0) { suiteName = suiteName.substring(suiteName.lastIndexOf('.')+1); } suiteName += "/"+System.getProperty("mithra.xml.config"); originalOut.println("Start Suite "+ suiteName); lastMessageTime = System.currentTimeMillis(); originalOut.flush(); flush(); }
Example #4
Source File: RhnCustomFormatter.java From spacewalk with GNU General Public License v2.0 | 6 votes |
/** * called when a test suite starts to run * @param suite a <code>JUnitTest</code> value */ public void startTestSuite(JUnitTest suite) { StringBuffer sb = new StringBuffer(); Object [] args = { "Running ", suite.getName() }; MessageFormat form = new MessageFormat("{0} {1}\n"); sb.append(form.format(args)); if (out != null) { try { out.write(sb.toString().getBytes()); out.flush(); } catch (IOException ioex) { throw new BuildException("Unable to write output", ioex); } // DO NOT CLOSE the out stream!!! } }
Example #5
Source File: RhnCustomFormatter.java From spacewalk with GNU General Public License v2.0 | 6 votes |
private void buildResultsMsg(JUnitTest suite, StringBuffer sb) { Object [] args = { suite.getName(), nf.format(suite.getRunTime() / RhnCustomFormatter.MS_PER_S), "ok" }; MessageFormat form = new MessageFormat("{0}({1}s): {2}\n\n"); long problemCount = suite.failureCount() + suite.errorCount(); if (problemCount > 0) { args[2] = problemCount + " NOT OK"; } sb.append(form.format(args)); }
Example #6
Source File: OneLinerFormatter.java From pxf with Apache License 2.0 | 5 votes |
@Override public void endTestSuite(JUnitTest suite) throws BuildException { StringBuffer sb = new StringBuffer("Tests run: "); sb.append(suite.runCount()); sb.append(", Failures: "); sb.append(suite.failureCount()); sb.append(", Errors: "); sb.append(suite.errorCount()); sb.append(", Time elapsed: "); sb.append(numberFormat.format(suite.getRunTime() / 1000.0)); sb.append(" sec"); sb.append(" (" + numberFormat.format(suite.getRunTime() / 1000.0 / 60)); sb.append(" min)"); sb.append(StringUtils.LINE_SEP); sb.append(StringUtils.LINE_SEP); if (output != null) { try { output.write(sb.toString()); resultWriter.close(); output.write(results.toString()); output.flush(); } finally { if (out != System.out && out != System.err) { FileUtils.close(out); } } } }
Example #7
Source File: RhnCustomFormatter.java From spacewalk with GNU General Public License v2.0 | 5 votes |
private void buildSummaryMsg(JUnitTest suite, StringBuffer sb) { Object [] args = { new Long(suite.runCount()), new Long(suite.failureCount()), new Long(suite.errorCount()), nf.format(suite.getRunTime() / RhnCustomFormatter.MS_PER_S) }; MessageFormat form = new MessageFormat( "Tests run: {0}, Failures: {1}, Errors: {2} Time elapsed: {3} sec\n"); sb.append(form.format(args)); }
Example #8
Source File: RhnCustomFormatter.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * called when the test suite finishes running. * most of the interesting stuff happens here. * prints out the overall timing, and success, * or any failures that occur * @param suite a <code>JUnitTest</code> * @exception BuildException if an error occurs */ public void endTestSuite(JUnitTest suite) throws BuildException { StringBuffer sb = new StringBuffer(); buildSummaryMsg(suite, sb); buildResultsMsg(suite, sb); if (out != null) { try { out.write(sb.toString().getBytes()); out.flush(); } catch (IOException ioex) { throw new BuildException("Unable to write output", ioex); } finally { if (out != System.out && out != System.err) { try { out.close(); } catch (IOException ioex2) { System.out.println(ioex2); } } } } }
Example #9
Source File: TestRunContainer.java From scipio-erp with Apache License 2.0 | 4 votes |
public boolean start() throws ContainerException { // configure log4j output logging if (logLevel != null) { int llevel = Debug.getLevelFromString(logLevel); for (int v = 0; v < 9; v++) { if (v < llevel) { Debug.set(v, false); } else { Debug.set(v, true); } } } // get the tests to run JunitSuiteWrapper jsWrapper = new JunitSuiteWrapper(component, suiteName, testCase); if (jsWrapper.getAllTestList().size() == 0) { throw new ContainerException("No tests found (" + component + " / " + suiteName + " / " + testCase + ")"); } boolean failedRun = false; for (ModelTestSuite modelSuite: jsWrapper.getModelTestSuites()) { Delegator testDelegator = modelSuite.getDelegator(); TestSuite suite = modelSuite.makeTestSuite(); JUnitTest test = new JUnitTest(); test.setName(suite.getName()); // create the XML logger JunitXmlListener xml; try { xml = new JunitXmlListener(new FileOutputStream(logDir + suite.getName() + ".xml")); } catch (FileNotFoundException e) { throw new ContainerException(e); } // per-suite results TestResult results = new TestResult(); results.addListener(new JunitListener()); results.addListener(xml); // add the suite to the xml listener xml.startTestSuite(test); // run the tests suite.run(results); test.setCounts(results.runCount(), results.failureCount(), results.errorCount()); // rollback all entity operations performed by the delegator testDelegator.rollback(); xml.endTestSuite(test); if (!results.wasSuccessful()) { failedRun = true; } // display the results Debug.logInfo("[JUNIT] Results for test suite: " + suite.getName(), module); Debug.logInfo("[JUNIT] Pass: " + results.wasSuccessful() + " | # Tests: " + results.runCount() + " | # Failed: " + results.failureCount() + " # Errors: " + results.errorCount(), module); if (Debug.importantOn() && !results.wasSuccessful()) { Debug.logInfo("[JUNIT] ----------------------------- ERRORS ----------------------------- [JUNIT]", module); Enumeration<?> err = results.errors(); if (!err.hasMoreElements()) { Debug.logInfo("None", module); } else { while (err.hasMoreElements()) { Object error = err.nextElement(); Debug.logInfo("--> " + error, module); if (error instanceof TestFailure) { Debug.logInfo(((TestFailure) error).trace(), module); } } } Debug.logInfo("[JUNIT] ------------------------------------------------------------------ [JUNIT]", module); Debug.logInfo("[JUNIT] ---------------------------- FAILURES ---------------------------- [JUNIT]", module); Enumeration<?> fail = results.failures(); if (!fail.hasMoreElements()) { Debug.logInfo("None", module); } else { while (fail.hasMoreElements()) { Object failure = fail.nextElement(); Debug.logInfo("--> " + failure, module); if (failure instanceof TestFailure) { Debug.logInfo(((TestFailure) failure).trace(), module); } } } Debug.logInfo("[JUNIT] ------------------------------------------------------------------ [JUNIT]", module); } } if (failedRun) { throw new ContainerException("Test run was unsuccessful"); } return true; }
Example #10
Source File: TestRunContainer.java From scipio-erp with Apache License 2.0 | 4 votes |
@Override public void startTestSuite(JUnitTest suite) { startTimes.put(suite.getName(), System.currentTimeMillis()); super.startTestSuite(suite); }
Example #11
Source File: TestRunContainer.java From scipio-erp with Apache License 2.0 | 4 votes |
@Override public void endTestSuite(JUnitTest suite) throws BuildException { long startTime = startTimes.get(suite.getName()); suite.setRunTime((System.currentTimeMillis() - startTime)); super.endTestSuite(suite); }
Example #12
Source File: JunitFormatter.java From reladomo with Apache License 2.0 | 4 votes |
public void endTestSuite(JUnitTest suite) throws BuildException { originalOut.println("End Suite "+suiteName+" Tests: "+tests+" Failures: "+failures+" Errors: "+errors); flush(); }
Example #13
Source File: JunitFormatter.java From gs-xsd2bean with Apache License 2.0 | 4 votes |
public void endTestSuite(JUnitTest suite) throws BuildException { originalOut.println("End Suite "+suiteName+" Tests: "+tests+" Failures: "+failures+" Errors: "+errors); flush(); }