@Override public void onTestStart(ITestResult result) { System.out.format("------- Starting test %s.%s(%s)-------\n", result.getTestClass(), result.getTestName(), Arrays.toString(result.getParameters())); }
@Override public void onTestSkipped(ITestResult result) { System.out.format("~~~~~~~~~ SKIPPED -- %s.%s(%s)-------", result.getTestClass(), result.getTestName(), Arrays.toString(result.getParameters())); }
@Override public void onTestSuccess(ITestResult result) { System.out.format("------- SUCCESS -- %s.%s(%s)-------", result.getTestClass(), result.getTestName(), Arrays.toString(result.getParameters())); }
private Map<String, List<ITestResult>> buildTestClassGroups(Set<ITestResult> testResults) { Map<String, List<ITestResult>> map = Maps.newHashMap(); for (ITestResult result : testResults) { String className = result.getTestClass().getName(); List<ITestResult> list = map.get(className); if (list == null) { list = Lists.newArrayList(); map.put(className, list); } list.add(result); } return map; }
@Override public int compare(ITestResult o1, ITestResult o2) { int result = o1.getTestClass().getName() .compareTo(o2.getTestClass().getName()); if (result == 0) { result = o1.getMethod().getMethodName() .compareTo(o2.getMethod().getMethodName()); } return result; } };
@Override public void onTestFailure(ITestResult result) { System.out.format("!!!!!!!!! FAILURE-- %s.%s(%s)-------\n", result.getTestClass(), result.getTestName(), Arrays.toString(result.getParameters())); if (result.getThrowable() instanceof ThreadTimeoutException) { System.out.println("====== THREAD DUMPS ======"); System.out.println(ThreadDumpUtil.buildThreadDiagnosticString()); } }
private Map<String, List<ITestResult>> buildTestClassGroups(Set<ITestResult> testResults) { Map<String, List<ITestResult>> map = Maps.newHashMap(); for (ITestResult result : testResults) { String className = result.getTestClass().getName(); List<ITestResult> list = map.computeIfAbsent(className, k -> Lists.newArrayList()); list.add(result); } return map; }
/** * Marks the current <code>TestResult</code> as skipped and invokes the listeners. */ private void handleConfigurationSkip(ITestNGMethod tm, ITestResult testResult, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, Object instance, XmlSuite suite) { recordConfigurationInvocationFailed(tm, testResult.getTestClass(), annotation, currentTestMethod, instance, suite); testResult.setStatus(ITestResult.SKIP); runConfigurationListeners(testResult, false /* after */); }
private void runAfterInvocationListeners(ITestResult tr) { InvokedMethod im = new InvokedMethod(tr.getTestClass(), tr.getMethod(), tr.getEndMillis(), tr); for (IInvokedMethodListener l: m_invokeListeners) { l.afterInvocation(im, tr); } }
/** * Marks the current <code>TestResult</code> as skipped and invokes the listeners. */ private void handleConfigurationSkip( ITestNGMethod tm, ITestResult testResult, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, Object instance, XmlSuite suite) { recordConfigurationInvocationFailed( tm, testResult.getTestClass(), annotation, currentTestMethod, instance, suite); testResult.setStatus(ITestResult.SKIP); runConfigurationListeners(testResult, false /* after */); }
private void runAfterInvocationListeners(ITestResult tr) { InvokedMethod im = new InvokedMethod(tr.getTestClass(), tr.getMethod(), tr.getEndMillis(), tr); for (IInvokedMethodListener l : m_invokeListeners) { l.afterInvocation(im, tr); } }
/** * @return the test results that apply to one of the instances of the testMethod. */ private Set<ITestResult> keepSameInstances(ITestNGMethod method, Set<ITestResult> results) { Set<ITestResult> result = Sets.newHashSet(); for (ITestResult r : results) { Object o = method.getInstance(); // Keep this instance if 1) It's on a different class or 2) It's on the same class // and on the same instance Object instance = r.getInstance() != null ? r.getInstance() : r.getMethod().getInstance(); if (r.getTestClass() != method.getTestClass() || instance == o) result.add(r); } return result; }
private void handleConfigurationFailure(Throwable ite, ITestNGMethod tm, ITestResult testResult, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, Object instance, XmlSuite suite) { Throwable cause= ite.getCause() != null ? ite.getCause() : ite; if(isSkipExceptionAndSkip(cause)) { testResult.setThrowable(cause); handleConfigurationSkip(tm, testResult, annotation, currentTestMethod, instance, suite); return; } Utils.log("", 3, "Failed to invoke configuration method " + tm.getQualifiedName() + ":" + cause.getMessage()); handleException(cause, tm, testResult, 1); runConfigurationListeners(testResult, false /* after */); // // If in TestNG mode, need to take a look at the annotation to figure out // what kind of @Configuration method we're dealing with // if (null != annotation) { recordConfigurationInvocationFailed(tm, testResult.getTestClass(), annotation, currentTestMethod, instance, suite); } }
private static void generateReport(ITestResult result) { StringBuilder builder = new StringBuilder(); String clsname = result.getTestClass().getRealClass().getName() + "."; String methodname = result.getMethod().getMethodName() + "()"; builder.append(clsname).append(methodname); Object[] parameters = result.getParameters(); if (parameters != null && parameters.length != 0) { builder.append(" Parameters:").append(Arrays.toString(parameters)); } Throwable throwable = result.getThrowable(); builder.append("\nException:\n"); builder.append(Utils.shortStackTrace(throwable, false)); builder.append("\n\n"); System.err.println(builder.toString()); } }
/** @return the test results that apply to one of the instances of the testMethod. */ private Set<ITestResult> keepSameInstances(ITestNGMethod method, Set<ITestResult> results) { Set<ITestResult> result = Sets.newHashSet(); for (ITestResult r : results) { Object o = method.getInstance(); // Keep this instance if 1) It's on a different class or 2) It's on the same class // and on the same instance Object instance = r.getInstance() != null ? r.getInstance() : r.getMethod().getInstance(); if (r.getTestClass() != method.getTestClass() || instance == o) { result.add(r); } } return result; }
private static String prettyMsg(ITestResult result) { return "Test method : " + result.getTestClass().getRealClass().getName() + "." + result.getMethod().getMethodName() + "()" + ", Parameters : " + Arrays.toString(result.getParameters()); }
private void failIfErrors(ITestResult result) { ErrorsCollector errorsCollector = SelenideLogger.removeListener(LISTENER_SOFT_ASSERT); if (errorsCollector != null) { try { errorsCollector.failIfErrors(result.getTestClass().getName() + '.' + result.getName()); } catch (AssertionError e) { result.setStatus(ITestResult.FAILURE); result.setThrowable(e); } } } }
void addSelenideErrorListener(ITestResult result) { boolean listenerAlreadyAdded = SelenideLogger.hasListener(LISTENER_SOFT_ASSERT); boolean hasSoftAssertListener = shouldIntercept(result.getTestClass().getRealClass()); boolean isTestMethod = shouldIntercept(result.getMethod().getConstructorOrMethod().getMethod()); if (hasSoftAssertListener && isTestMethod && !listenerAlreadyAdded) { SelenideLogger.addListener(LISTENER_SOFT_ASSERT, new ErrorsCollector()); } else if (hasSoftAssertListener && !listenerAlreadyAdded) { SelenideLogger.addListener(LISTENER_SOFT_ASSERT, new ErrorsCollector()); } }
ListMultiMap<Class<?>, ITestResult> map = Maps.newListMultiMap(); for (ITestResult m : tests.getAllResults()) { map.put(m.getTestClass().getRealClass(), m);
"hash-for-method", getModel().getTag(tr), "panel-name", suiteName, "title", tr.getTestClass().getName(), C, "method navigator-link"); xsb.pop(S);