Package org.testng

Examples of org.testng.ITestNGMethod


      if (l.size() > 1) {
        // Sort them
        sortMethodsByInheritance(l, baseClassToChild);
       
        for (int i = 0; i < l.size(); i++) {
          ITestNGMethod m1 = l.get(i);
          // Look for any method further down that is a subclass of this one.
          // This handles the case when there are multiple BeforeClass/AfterClass
          // methods in the same class.
          for (int j = i + 1; j < l.size(); j++) {
            ITestNGMethod m2 = l.get(j);
            if (! equalsEffectiveClass(m1, m2)) {
              Utils.log("MethodInheritance", 4, m2 + " DEPENDS ON " + m1);
              m2.addMethodDependedUpon(MethodHelper.calculateMethodCanonicalName(m1));
            }
          }
        }
      }
    }
View Full Code Here


                continue;
              }
             
              String key = createMethodKey(m);
              if (null == vResult.get(key)) {
                ITestNGMethod tm = new TestNGMethod(/* m.getDeclaringClass(), */ m, annotationFinder);
                vResult.put(key,tm);
              }
            }
          } // for
          // Now explore the superclass
View Full Code Here

  public void onFinish(ITestContext testContext) {
    ReportPrinter.printHtmlReport(userGroups, methods);
  }

  private static void addResult(ITestResult result, Status status) {
    ITestNGMethod method = result.getMethod();
    if (method.isTest() == false) {
      return;
    }
    long duration = result.getEndMillis() - result.getStartMillis();
    String[] groups = method.getGroups();
    String methodName = method.getMethodName();
    String clazzName = method.getRealClass().getName();
    methods.add(new MethodTestDto(methodName, clazzName, status, duration, groups));

    if (groups == null) {
      UserGroupDto userDto = getUserGroupDto(MethodTestDto.UN_GROUP_NAME);
      userDto.addResult(status);
View Full Code Here

public class JTesterMethodsOrder implements IMethodInterceptor {

  public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
    Map<String, List<IMethodInstance>> map = new HashMap<String, List<IMethodInstance>>();
    for (IMethodInstance mi : methods) {
      ITestNGMethod method = mi.getMethod();
      Object[] instances = mi.getInstances();
      if (instances == null || instances.length == 0) {
        continue;
      }
      Object instance = instances[0];
View Full Code Here

                                      String[] beforeGroups,
                                      String[] afterGroups,
                                      Object instance)
  {
    if(method.getDeclaringClass().isAssignableFrom(clazz)) {
      ITestNGMethod confMethod = new ConfigurationMethod(method,
                                                         m_annotationFinder,
                                                         isBeforeSuite,
                                                         isAfterSuite,
                                                         isBeforeTest,
                                                         isAfterTest,
View Full Code Here

    // Fix the method inheritance if these are @Configuration methods to make
    // sure base classes are invoked before child classes if 'before' and the
    // other way around if they are 'after'
    if (!forTests && allMethodsArray.length > 0) {
      ITestNGMethod m = allMethodsArray[0];
      boolean before = m.isBeforeClassConfiguration()
          || m.isBeforeMethodConfiguration() || m.isBeforeSuiteConfiguration()
          || m.isBeforeTestConfiguration();
      MethodInheritance.fixMethodInheritance(allMethodsArray, before);
    }

    topologicalSort(allMethodsArray, sl, pl);
View Full Code Here

                continue;
              }

              String key = createMethodKey(m);
              if (null == vResult.get(key)) {
                ITestNGMethod tm = new TestNGMethod(/* m.getDeclaringClass(), */ m,
                    annotationFinder, xmlTest, null); /* @@@ */
                vResult.put(key,tm);
              }
            }
          } // for
View Full Code Here

        // Depends on methods?
        // Adds all depended methods to runningMethods
        //
        String[] mdu = m.getMethodsDependedUpon();
        for (String tm : mdu) {
          ITestNGMethod thisMethod = MethodGroupsHelper.findMethodNamed(tm, allMethods);
          if (thisMethod != null && ! runningMethods.containsKey(thisMethod)) {
            runningMethods.put(thisMethod, thisMethod);
            newMethods.put(thisMethod, thisMethod);
          }
        }
View Full Code Here

        if (isConfMethod) {
            sb.append(" CONFIGURATION: ");
        } else {
            sb.append(": ");
        }
        ITestNGMethod tm = itr.getMethod();
        int identLevel = sb.length();
        sb.append(getMethodDeclaration(tm));
        Object[] params = itr.getParameters();
        Class[] paramTypes = tm.getMethod().getParameterTypes();
        if (null != params && params.length > 0) {
            // The error might be a data provider parameter mismatch, so make
            // a special case here
            if (params.length != paramTypes.length) {
                sb.append("Wrong number of arguments were passed by the Data Provider: found ");
                sb.append(params.length);
                sb.append(" but expected ");
                sb.append(paramTypes.length);
            } else {
                sb.append("(value(s): ");
                for (int i = 0; i < params.length; i++) {
                    if (i > 0) {
                        sb.append(", ");
                    }
                    sb.append(Utils.toString(params[i], paramTypes[i]));
                }
                sb.append(")");

            }
        }
        if (Status.STARTED != st) {
            sb.append(" finished in ");
            sb.append(itr.getEndMillis() - itr.getStartMillis());
            sb.append(" ms");
            if (!Utils.isStringEmpty(tm.getDescription())) {
                sb.append("\n");
                for (int i = 0; i < identLevel; i++) {
                    sb.append(" ");
                }
                sb.append(tm.getDescription());
            }
            if (tm.getInvocationCount() > 1) {
                sb.append(" (");
                sb.append(tm.getCurrentInvocationCount());
                sb.append(" of ");
                sb.append(tm.getInvocationCount());
                sb.append(")");
            }
            if (!Utils.isStringEmpty(stackTrace)) {
                sb.append("\n").append(stackTrace.substring(0, stackTrace.lastIndexOf(System.getProperty("line.separator"))));
            }
        } else {
            if (!isConfMethod && tm.getInvocationCount() > 1) {
                sb.append(" success: ");
                sb.append(tm.getSuccessPercentage());
                sb.append("%");
            }
        }
        log(sb.toString());
    }
View Full Code Here

    List<IWorker<ITestNGMethod>> workers = Lists.newArrayList();

    // Create one worker per invocationCount
    for (int i = 0; i < testMethod.getInvocationCount(); i++) {
      // we use clones for reporting purposes
      ITestNGMethod clonedMethod= testMethod.clone();
      clonedMethod.setInvocationCount(1);
      clonedMethod.setThreadPoolSize(1);

      MethodInstance mi = new MethodInstance(clonedMethod);
      workers.add(new SingleTestMethodWorker(this,
          mi,
          suite,
View Full Code Here

TOP

Related Classes of org.testng.ITestNGMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.