@Override public int compare(ITestResult o1, ITestResult o2) { return (int) (o1.getStartMillis() - o2.getStartMillis()); } });
@Override public int compare(ITestResult o1, ITestResult o2) { long t1 = o1.getEndMillis() - o1.getStartMillis(); long t2 = o2.getEndMillis() - o2.getStartMillis(); return (int) (t2 - t1); } });
@Override public int compare(IInvokedMethod arg0, IInvokedMethod arg1) { return (int) (arg0.getTestResult().getStartMillis() - arg1.getTestResult().getStartMillis()); } });
@Override public int compareTo(ITestResult comparison) { return Long.compare(getStartMillis(), comparison.getStartMillis()); }
@SuppressWarnings("unchecked") private void addAllTestResults(Set<ITestResult> testResults, IResultMap resultMap) { if (resultMap != null) { // Sort the results chronologically before adding them List<ITestResult> allResults = new ArrayList<>(resultMap.getAllResults()); new ArrayList(allResults) .sort( (Comparator<ITestResult>) (o1, o2) -> (int) (o1.getStartMillis() - o2.getStartMillis())); testResults.addAll(allResults); } }
@Override public int compare(IInvokedMethod arg0, IInvokedMethod arg1) { return (int) (arg0.getTestResult().getStartMillis() - arg1.getTestResult().getStartMillis()); } });
@Override public int compareTo(@Nonnull ITestResult comparison) { return Long.compare(getStartMillis(), comparison.getStartMillis()); }
private static long time(ITestResult o1) { return o1.getEndMillis() - o1.getStartMillis(); }
/** * Add the time of the configuration method to this test method. * * The only problem with this method is that the timing of a test method * might not be added to the time of the same configuration method that ran before * it but since they should all be equivalent, this should never be an issue. */ private long getNextConfiguration(ListMultiMap<Object, ITestResult> configurations, ITestResult tr) { long result = 0; List<ITestResult> confResults = configurations.get(tr.getInstance()); Map<ITestNGMethod, ITestResult> seen = Maps.newHashMap(); for (ITestResult r : confResults) { if (! seen.containsKey(r.getMethod())) { result += r.getEndMillis() - r.getStartMillis(); seen.put(r.getMethod(), r); } } confResults.removeAll(seen.values()); return result; }
@Override public void testIgnored(Description description) throws Exception { if (!notified.contains(description)) { notified.add(description); ITestResult tr = m_findedMethods.get(description); validate(tr, description); runAfterInvocationListeners(tr); tr.setStatus(TestResult.SKIP); tr.setEndMillis(tr.getStartMillis()); m_parentRunner.addSkippedTest(tr.getMethod(), tr); m_methods.add(tr.getMethod()); for (ITestListener l : m_listeners) { l.onTestSkipped(tr); } } }
@Override public void onConfigurationFailure(ITestResult itr) { executionTime = itr.getEndMillis() - itr.getStartMillis(); }
for (ITestResult tr : allTestResults) { ITestNGMethod m = tr.getMethod(); long time = tr.getEndMillis() - tr.getStartMillis(); result .append("data.setCell(" + index + ", "
/** * Add the time of the configuration method to this test method. * * <p>The only problem with this method is that the timing of a test method might not be added to * the time of the same configuration method that ran before it but since they should all be * equivalent, this should never be an issue. */ private long getNextConfiguration( ListMultiMap<Object, ITestResult> configurations, ITestResult tr) { long result = 0; List<ITestResult> confResults = configurations.get(tr.getInstance()); Map<ITestNGMethod, ITestResult> seen = Maps.newHashMap(); for (ITestResult r : confResults) { if (!seen.containsKey(r.getMethod())) { result += r.getEndMillis() - r.getStartMillis(); seen.put(r.getMethod(), r); } } confResults.removeAll(seen.values()); return result; }
private void generateMethod(String tagClass, ITestResult tr, ITestContext context, XMLStringBuffer xsb) { long time = tr.getEndMillis() - tr.getStartMillis(); xsb.push(D, C, "method"); xsb.push(D, C, "method-content"); xsb.addOptional(S, tr.getMethod().getMethodName(), C, "method-name"); // Parameters? if (tr.getParameters().length > 0) { StringBuilder sb = new StringBuilder(); boolean first = true; for (Object p : tr.getParameters()) { if (!first) sb.append(", "); first = false; sb.append(Utils.toString(p)); } xsb.addOptional(S, "(" + sb.toString() + ")", C, "parameters"); } // Exception? if (tr.getThrowable() != null) { StringBuilder stackTrace = new StringBuilder(); for (StackTraceElement str : tr.getThrowable().getStackTrace()) { stackTrace.append(str.toString()).append("<br>"); } xsb.addOptional(D, stackTrace.toString() + "\n", C, "stack-trace"); } xsb.addOptional(S, " " + Long.toString(time) + " ms", C, "method-time"); xsb.pop(D); xsb.pop(D); }
@Override public void testIgnored(Description description) throws Exception { if (!notified.contains(description)) { notified.add(description); ITestResult tr = m_findedMethods.get(description); validate(tr, description); runAfterInvocationListeners(tr); tr.setStatus(TestResult.SKIP); tr.setEndMillis(tr.getStartMillis()); m_parentRunner.addSkippedTest(tr.getMethod(), tr); m_methods.add(tr.getMethod()); for (ITestListener l : m_listeners) { l.onTestSkipped(tr); } } }
@AfterMethod(alwaysRun = true) public void endTestSuite(final Method method, final ITestResult result) throws Exception { if (hasFailed()) { return; } log.info("***************************************************************************************************"); log.info("*** Ending test {}:{} {} ({} s.)", new Object[]{method.getDeclaringClass().getName(), method.getName(), result.isSuccess() ? "SUCCESS" : "!!! FAILURE !!!", (result.getEndMillis() - result.getStartMillis()) / 1000}); log.info("***************************************************************************************************"); if (!hasFailed && !result.isSuccess()) { hasFailed = true; } }
String startTime = TimeUtils.timeInUTC(testResult.getStartMillis(), config.getTimestampFormat()); String endTime = TimeUtils.timeInUTC(testResult.getEndMillis(), config.getTimestampFormat()); attributes.setProperty(XMLReporterConfig.ATTR_STARTED_AT, startTime); attributes.setProperty(XMLReporterConfig.ATTR_FINISHED_AT, endTime); long duration = testResult.getEndMillis() - testResult.getStartMillis(); String strDuration = Long.toString(duration); attributes.setProperty(XMLReporterConfig.ATTR_DURATION_MS, strDuration);
private void createElement(XMLStringBuffer doc, ITestResult tr) { long elapsedTimeMillis= tr.getEndMillis() - tr.getStartMillis(); Properties attrs= getPropertiesFor(tr.getMethod(), elapsedTimeMillis); if (tr.getMethod().isTest()) { attrs.setProperty(XMLConstants.ATTR_NAME, tr.getName()); } if((ITestResult.FAILURE == tr.getStatus()) || (ITestResult.SKIP == tr.getStatus())) { doc.push(XMLConstants.TESTCASE, attrs); if(ITestResult.FAILURE == tr.getStatus()) { createFailureElement(doc, tr); } else if(ITestResult.SKIP == tr.getStatus()) { createSkipElement(doc); } doc.pop(); } else { doc.addEmptyElement(XMLConstants.TESTCASE, attrs); } }
start = tr.getStartMillis(); xsb.addRequired(S, Long.toString(tr.getStartMillis() - start) + " ms", C, "method-start"); xsb.pop(D);
private void createElement(XMLStringBuffer doc, ITestResult tr) { long elapsedTimeMillis = tr.getEndMillis() - tr.getStartMillis(); Properties attrs = getPropertiesFor(tr.getMethod(), elapsedTimeMillis); if (tr.getMethod().isTest()) { attrs.setProperty(XMLConstants.ATTR_NAME, tr.getName()); } if ((ITestResult.FAILURE == tr.getStatus()) || (ITestResult.SKIP == tr.getStatus())) { doc.push(XMLConstants.TESTCASE, attrs); if (ITestResult.FAILURE == tr.getStatus()) { createFailureElement(doc, tr); } else if (ITestResult.SKIP == tr.getStatus()) { createSkipElement(doc); } doc.pop(); } else { doc.addEmptyElement(XMLConstants.TESTCASE, attrs); } }