Refine search
long start = 0; for (IInvokedMethod im : invokedMethods) { ITestNGMethod m = im.getTestMethod(); if (m.isBeforeSuiteConfiguration()) { cls = "configuration-suite before"; } else if (m.isAfterSuiteConfiguration()) { cls = "configuration-suite after"; } else if (m.isBeforeTestConfiguration()) { cls = "configuration-test before"; } else if (m.isAfterTestConfiguration()) { cls = "configuration-method after"; ITestResult tr = im.getTestResult(); String methodName = Model.getTestResultName(tr); if (tr.getStatus() == ITestResult.FAILURE) { xsb.push("img", "src", Model.getImage("failed")); xsb.pop("img"); start = tr.getStartMillis(); xsb.addRequired(S, Long.toString(tr.getStartMillis() - start) + " ms", C, "method-start"); xsb.pop(D);
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { String methodName = method.getTestMethod().getMethodName(); if (method.isTestMethod()) { testMethods.add(methodName); } if (method.isConfigurationMethod()) { configurationMethods.add(methodName); } if (method.getTestMethod().isTest()) { testMethodsFromTM.add(methodName); } if (method.getTestMethod().isBeforeMethodConfiguration() || method.getTestMethod().isAfterMethodConfiguration() || method.getTestMethod().isBeforeTestConfiguration() || method.getTestMethod().isAfterTestConfiguration() || method.getTestMethod().isBeforeClassConfiguration() || method.getTestMethod().isAfterClassConfiguration() || method.getTestMethod().isBeforeSuiteConfiguration() || method.getTestMethod().isAfterSuiteConfiguration()) { configurationMethodsFromTM.add(methodName); } } }
public static List<ITestNGMethod> invokedMethodsToMethods(Collection<IInvokedMethod> invokedMethods) { List<ITestNGMethod> result = Lists.newArrayList(); for (IInvokedMethod im : invokedMethods) { ITestNGMethod tm = im.getTestMethod(); tm.setDate(im.getDate()); result.add(tm); } return result; }
private static Throwable getConfigFailureException(ITestContext context) { for (IInvokedMethod method : context.getSuite().getAllInvokedMethods()) { ITestNGMethod m = method.getTestMethod(); if (m.isBeforeSuiteConfiguration() && (!method.getTestResult().isSuccess())) { return method.getTestResult().getThrowable(); } } return null; }
public static void dumpInvokedMethodsInfoToConsole(Collection<IInvokedMethod> iInvokedMethods, int currentVerbosity) { if (currentVerbosity < 3) { return; } System.out.println("===== Invoked methods"); for (IInvokedMethod im : iInvokedMethods) { if (im.isTestMethod()) { System.out.print(" "); } else if (im.isConfigurationMethod()) { System.out.print(" "); } else { continue; } System.out.println("" + im); } System.out.println("====="); }
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { if (method.isTestMethod()) { Method testMethod = method.getTestMethod().getConstructorOrMethod().getMethod(); TestCoverage.INSTANCE.setCurrentTestMethod(testMethod); } }
ITestNGMethod m = invokedMethod.getTestMethod(); String declaringClassName = m.getConstructorOrMethod().getMethod().getDeclaringClass().getName(); String testClassName = m.getTestClass().getName(); if (!classesToRerun.contains(testClassName) && declaringClassName.equals(testClassName)) if (m.isBeforeClassConfiguration() || m.isAfterClassConfiguration()) LOGGER.info("SKIPPING CONFIGURATION METHOD: " + declaringClassName + " : " + m.getMethodName() for (XmlClass cl : testResult.getTestContext().getCurrentXmlTest().getClasses())
private static boolean annotationPresent(IInvokedMethod method, Class<? extends Annotation> clazz) { return method.getTestMethod().getConstructorOrMethod().getMethod().isAnnotationPresent(clazz); }
/** * This method helps in creating a Test runner neutral object that represents a method. * * @param method * - An {@link IInvokedMethod} that represents the current invoked method. * @param result * - An {@link ITestResult} object that represents a test result. * @return - A {@link InvokedMethodInformation} that represents the current invoked method. */ public static InvokedMethodInformation getInvokedMethodInformation(IInvokedMethod method, ITestResult result) { logger.entering(new Object[] { method, result }); InvokedMethodInformation methodInfo = new InvokedMethodInformation(); methodInfo.setMethodParameters(result.getParameters()); methodInfo.setActualMethod(method.getTestMethod().getConstructorOrMethod().getMethod()); methodInfo.setTestMethodAttributes(extractAttributes(result)); methodInfo.setCurrentMethodName(method.getTestMethod().getMethodName()); methodInfo.setCurrentTestName(result.getTestContext().getCurrentXmlTest().getName()); methodInfo.setTestResultSuccess(result.isSuccess()); methodInfo.setException(result.getThrowable()); methodInfo.setMethodsDependedUpon(method.getTestMethod().getMethodsDependedUpon()); logger.exiting(methodInfo); return methodInfo; }
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { if (method.isTestMethod()) { logger.info("> Running [{}.{}]", method.getTestMethod().getTestClass().getRealClass().getSimpleName(), method.getTestMethod().getMethodName()); } }
private boolean isHighPriority(IInvokedMethod method) { if (!isAnnotatedWithTest(method)) { // Abort. There will already be an exception thrown in isLowPriority for this case. return true; } int high = method.getTestMethod().getPriority(); for (ITestNGMethod test : method.getTestMethod().getTestClass().getTestMethods()) { if (test.getEnabled() && test.getPriority() > high) { return false; } } Test t = method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class); // For a test method with a data provider if (!(t.dataProvider().isEmpty())) { int currentInvocationCount = method.getTestMethod().getCurrentInvocationCount(); int parameterInvocationCount = method.getTestMethod().getParameterInvocationCount(); // If the data set from the data provider is exhausted // It means its the last method with the data provider- this is the exit condition return (currentInvocationCount == parameterInvocationCount); } return true; }
@Override public void beforeInvocation(@Nonnull IInvokedMethod invokedMethod, @Nonnull ITestResult testResult) { ITestNGMethod testNGMethod = testResult.getMethod(); Class<?> testClass = testResult.getTestClass().getRealClass(); if (!invokedMethod.isTestMethod()) { beforeConfigurationMethod(testNGMethod, testClass); return; Method method = testNGMethod.getConstructorOrMethod().getMethod(); exportCurrentTestMethodIfApplicable(method); Object testInstance = testResult.getInstance();
boolean addedHeader = false; for (IInvokedMethod iim : invokedMethods) { ITestNGMethod tm = iim.getTestMethod(); if (!addedHeader) { bw.append("<table border=\"1\">\n") boolean bc = tm.isBeforeClassConfiguration(); boolean ac = tm.isAfterClassConfiguration(); boolean bt = tm.isBeforeTestConfiguration(); boolean at = tm.isAfterTestConfiguration(); boolean bs = tm.isBeforeSuiteConfiguration(); startDate = iim.getDate(); String date = format.format(iim.getDate()); bw.append("<tr bgcolor=\"").append(createColor(tm)).append("\">") .append(" <td>").append(date).append("</td> ") .append(" <td>").append(Long.toString(iim.getDate() - startDate)).append("</td> ") .append(td(configurationSuiteMethod)) .append(td(configurationTestMethod))
@Override public int compare(Object o1, Object o2) { IInvokedMethod m1 = (IInvokedMethod) o1; IInvokedMethod m2 = (IInvokedMethod) o2; return m1.getTestMethod().getMethodName().compareTo(m2.getTestMethod().getMethodName()); } };
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { List<String> methodNames = mapping.computeIfAbsent(testResult.getMethod().getRealClass(), k -> Lists.newArrayList()); methodNames.add(method.getTestMethod().getMethodName()); String name = getName(testResult); switch (testResult.getStatus()) { case ITestResult.FAILURE: if (!(skipConfiguration && method.isConfigurationMethod())) { failedMethodNames.add(name); } break; case ITestResult.SKIP: if (!(skipConfiguration && method.isConfigurationMethod())) { if (wantSkippedMethodAfterInvocation) { skippedAfterInvocationMethodNames.add(name); } } break; case ITestResult.SUCCESS: if (!(skipConfiguration && method.isConfigurationMethod())) { succeedMethodNames.add(name); } break; default: throw new AssertionError("Unexpected value: " + testResult.getStatus()); } }
@Override public void beforeInvocation(final IInvokedMethod method, final ITestResult testResult) { testInstance = method.getTestMethod().getInstance(); testMethod = method.getTestMethod().getConstructorOrMethod().getMethod(); if (isListening()) { handler.inject(testInstance, testMethod); injectTestResources(testInstance, testMethod); } }
@Override public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) { if (method.isTestMethod()) { UnitSupport.getInstance().afterScript(method.getTestMethod().getMethodName(), testResult.isSuccess(), testResult.getThrowable()); } }
Map<String, Tuple<FullResult, List<Testcase>>> full = new HashMap<>(); for(IInvokedMethod meth: invoked) { ITestNGMethod fn = meth.getTestMethod(); if (!fn.isTest()) { continue; ITestClass clz = fn.getTestClass(); String methname = fn.getMethodName(); String classname = clz.getName(); tests.add(testcase); ITestResult result = meth.getTestResult(); Double millis = (result.getEndMillis() - result.getStartMillis()) / 1000.0;
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { try { if (ListenerManager.isCurrentMethodSkipped(this)) { logger.exiting(ListenerManager.THREAD_EXCLUSION_MSG); return; } Test testMethod = method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class); if (testMethod != null) { String testName = testMethod.testName(); if (StringUtils.isNotEmpty(testName)) { testResult.setAttribute(TEST_NAME_KEY, testName); } } } catch (Exception e) { //NOSONAR logger.log(Level.WARNING, "An error occurred while processing beforeInvocation: " + e.getMessage(), e); } }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { m_afterCount++; if (method.getTestMethod().isAfterSuiteConfiguration()) { suiteStatus = testResult.getStatus(); suiteThrowable = testResult.getThrowable(); } if (method.getTestMethod().isTest()) { methodStatus = testResult.getStatus(); methodThrowable = testResult.getThrowable(); } }