String canonicalMethodName = calculateMethodCanonicalName(m); MatchResults results = matchMethod(methods, regexp); foundAtLeastAMethod = results.foundAtLeastAMethod; vResult.addAll(results.matchedMethods); if (lastIndex != -1) { newMethodName = m.getTestClass().getRealClass().getName() + regexp.substring(lastIndex); results = matchMethod(methods, newMethodName); foundAtLeastAMethod = results.foundAtLeastAMethod; vResult.addAll(results.matchedMethods); continue; Method maybeReferringTo = findMethodByName(m, regexp); if (maybeReferringTo != null) { throw new TestNGException(canonicalMethodName + "() is depending on method "
private void dumpInvokedMethods() { MethodHelper.dumpInvokedMethodsInfoToConsole(m_invokedMethods, getVerbose()); }
/** * Finds TestNG methods that the specified TestNG method depends upon * @param m TestNG method * @param methods list of methods to search for depended upon methods * @return list of methods that match the criteria */ protected static ITestNGMethod[] findDependedUponMethods(ITestNGMethod m, List<ITestNGMethod> methods) { ITestNGMethod[] methodsArray = methods.toArray(new ITestNGMethod[methods.size()]); return findDependedUponMethods(m, methodsArray); }
fixMethodsWithClass(tc.getTestMethods(), tc, testMethods); fixMethodsWithClass(tc.getBeforeClassMethods(), tc, beforeClassMethods); fixMethodsWithClass(tc.getBeforeTestMethods(), tc, null); fixMethodsWithClass(tc.getAfterTestMethods(), tc, null); fixMethodsWithClass(tc.getAfterClassMethods(), tc, afterClassMethods); fixMethodsWithClass(tc.getBeforeSuiteMethods(), tc, beforeSuiteMethods); fixMethodsWithClass(tc.getAfterSuiteMethods(), tc, afterSuiteMethods); fixMethodsWithClass(tc.getBeforeTestConfigurationMethods(), tc, beforeXmlTestMethods); fixMethodsWithClass(tc.getAfterTestConfigurationMethods(), tc, afterXmlTestMethods); fixMethodsWithClass(tc.getBeforeGroupsMethods(), tc, MethodHelper.uniqueMethodList(beforeGroupMethods.values())); fixMethodsWithClass(tc.getAfterGroupsMethods(), tc, MethodHelper.uniqueMethodList(afterGroupMethods.values())); m_beforeSuiteMethods = MethodHelper.collectAndOrderMethods(beforeSuiteMethods, false /* forTests */, m_runInfo, m_beforeXmlTestMethods = MethodHelper.collectAndOrderMethods(beforeXmlTestMethods, false /* forTests */, m_runInfo, m_allTestMethods = MethodHelper.collectAndOrderMethods(testMethods, true /* forTest? */, m_runInfo, m_afterXmlTestMethods = MethodHelper.collectAndOrderMethods(afterXmlTestMethods, false /* forTests */, m_runInfo,
boolean alwaysRun = MethodHelper.isAlwaysRun(configurationAnnotation); boolean canProcessMethod = MethodHelper.isEnabled(objectClass, m_annotationFinder) || alwaysRun; if (!canProcessMethod) { log(3, "Skipping " + Utils.detailedMethodName(tm, true) continue; if (MethodHelper.isDisabled(configurationAnnotation)) { log(3, "Skipping " + Utils.detailedMethodName(tm, true) + " because it is not enabled");
protected static String calculateMethodCanonicalName(Class<?> methodClass, String methodName) { Set<Method> methods = ClassHelper.getAvailableMethods(methodClass); // TESTNG-139 Method result = null; for (Method m : methods) { if (methodName.equals(m.getName())) { result = m; break; } } return result != null ? calculateMethodCanonicalName(result) : null; }
protected static void invokeMethodConsideringTimeout(ITestNGMethod tm, ConstructorOrMethod method, Object targetInstance, Object[] params, ITestResult testResult) throws Throwable { if (MethodHelper.calculateTimeOut(tm) <= 0) { MethodInvocationHelper.invokeMethod(method.getMethod(), targetInstance, params); } else { MethodInvocationHelper.invokeWithTimeout(tm, targetInstance, params, testResult); if (!testResult.isSuccess()) { // A time out happened Throwable ex = testResult.getThrowable(); testResult.setStatus(ITestResult.FAILURE); testResult.setThrowable(ex.getCause() == null ? ex : ex.getCause()); throw testResult.getThrowable(); } } }
Map<Object, List<ITestNGMethod>> testInstances = sortMethodsByInstance(methods); try { methodsNamed = MethodHelper.findDependedUponMethods(m, instanceMethods); } catch (TestNGException e) { methodsNamed = MethodHelper.findDependedUponMethods(m, methods); methodsNamed = MethodHelper.findDependedUponMethods(m, methods);
private static List<ITestNGMethod> associateInstanceToMethods( Class<?> clazz, XmlTest xmlTest, Class<? extends IAnnotation> annotationClass) { ITestClass testClass = new FakeTestClass(clazz); ITestNGMethod[] rawMethods = methods(clazz, xmlTest, annotationClass); Object object = newInstance(clazz); List<ITestNGMethod> fixedMethods = Lists.newArrayList(); if (object == null) { // Looks like there was a non default constructor on the class (maybe because its driven by a // factory) // So lets not try to associate the instance. We will use the method as is. fixedMethods.addAll(Arrays.asList(rawMethods)); } else { for (ITestNGMethod each : rawMethods) { ITestNGMethod m = new TestNGMethod(each.getConstructorOrMethod().getMethod(), finder, xmlTest, object); fixedMethods.add(m); } } List<ITestNGMethod> tstMethods = Lists.newArrayList(); MethodHelper.fixMethodsWithClass( fixedMethods.toArray(new ITestNGMethod[0]), testClass, tstMethods); return tstMethods; }
public List<ITestNGMethod> getInvokedMethods() { return MethodHelper.invokedMethodsToMethods(m_invokedMethods); }
List<ITestNGMethod> methodsDependedUpon = MethodHelper.getMethodsDependedUpon(current, context.getAllTestMethods(), Systematiser.getComparator());
return MethodHelper.collectAndOrderMethods(Lists.newArrayList(vResult), false /* forTests */, runInfo,
fixMethodsWithClass(tc.getTestMethods(), tc, testMethods); fixMethodsWithClass(tc.getBeforeClassMethods(), tc, beforeClassMethods); fixMethodsWithClass(tc.getBeforeTestMethods(), tc, null); fixMethodsWithClass(tc.getAfterTestMethods(), tc, null); fixMethodsWithClass(tc.getAfterClassMethods(), tc, afterClassMethods); fixMethodsWithClass(tc.getBeforeSuiteMethods(), tc, beforeSuiteMethods); fixMethodsWithClass(tc.getAfterSuiteMethods(), tc, afterSuiteMethods); fixMethodsWithClass(tc.getBeforeTestConfigurationMethods(), tc, beforeXmlTestMethods); fixMethodsWithClass(tc.getAfterTestConfigurationMethods(), tc, afterXmlTestMethods); fixMethodsWithClass( tc.getBeforeGroupsMethods(), tc, MethodHelper.uniqueMethodList(beforeGroupMethods.values())); fixMethodsWithClass( tc.getAfterGroupsMethods(), tc, MethodHelper.uniqueMethodList(afterGroupMethods.values())); MethodHelper.collectAndOrderMethods( beforeSuiteMethods, false /* forTests */, MethodHelper.collectAndOrderMethods( beforeXmlTestMethods, false /* forTests */, MethodHelper.collectAndOrderMethods( testMethods, true /* forTest? */,
boolean alwaysRun = MethodHelper.isAlwaysRun(configurationAnnotation); boolean canProcessMethod = MethodHelper.isEnabled(objectClass, annotationFinder()) || alwaysRun; if (!canProcessMethod) { log( continue; if (MethodHelper.isDisabled(configurationAnnotation)) { log(3, "Skipping " + Utils.detailedMethodName(tm, true) + " because it is not enabled"); continue;
protected static String calculateMethodCanonicalName(Class<?> methodClass, String methodName) { Set<Method> methods = ClassHelper.getAvailableMethods(methodClass); // TESTNG-139 Method result = null; for (Method m : methods) { if (methodName.equals(m.getName())) { result = m; break; } } return result != null ? calculateMethodCanonicalName(result) : null; }
private static void invokeWithTimeoutWithNoExecutor(ITestNGMethod tm, Object instance, Object[] parameterValues, ITestResult testResult, IHookable hookable) { InvokeMethodRunnable imr = new InvokeMethodRunnable(tm, instance, parameterValues, hookable, testResult); long startTime = System.currentTimeMillis(); long realTimeOut = MethodHelper.calculateTimeOut(tm); try { imr.run(); if (System.currentTimeMillis() <= startTime + realTimeOut) { testResult.setStatus(ITestResult.SUCCESS); } else { ThreadTimeoutException exception = new ThreadTimeoutException("Method " + tm.getQualifiedName() + "()" + " didn't finish within the time-out " + realTimeOut); testResult.setThrowable(exception); testResult.setStatus(ITestResult.FAILURE); } } catch (Exception ex) { testResult.setThrowable(ex.getCause()); testResult.setStatus(ITestResult.FAILURE); } }
Map<Object, List<ITestNGMethod>> testInstances = sortMethodsByInstance(methods); try { methodsNamed = MethodHelper.findDependedUponMethods(m, instanceMethods); } catch (TestNGException e) { methodsNamed = MethodHelper.findDependedUponMethods(m, methods); methodsNamed = MethodHelper.findDependedUponMethods(m, methods);
ITestClass testClass = new FakeTestClass(clazz); List<ITestNGMethod> tstMethods = Lists.newArrayList(); MethodHelper.fixMethodsWithClass(allMethods, testClass, tstMethods);
public List<ITestNGMethod> getInvokedMethods() { return MethodHelper.invokedMethodsToMethods(m_invokedMethods); }
MethodHelper.getMethodsDependedUpon( current, context.getAllTestMethods(), Systematiser.getComparator());