All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.testng.PreserveOrderMethodInterceptor Maven / Gradle / Ivy

There is a newer version: 7.10.2
Show newest version
package org.testng;

import org.testng.internal.MethodInstance;

import java.util.Collections;
import java.util.List;

/**
 * A method interceptor that preserves the order in which test classes were found in
 * the <test> tag.
 *
 * @author cbeust
 *
 */
class PreserveOrderMethodInterceptor implements IMethodInterceptor {

  private void p(List methods, String s) {
    System.out.println("[PreserveOrderMethodInterceptor] " + s);
    for (IMethodInstance mi : methods) {
      System.out.println("  " + mi.getMethod().getMethodName()
          + " index:" + mi.getMethod().getTestClass().getXmlClass().getIndex());
    }
  }

  @Override
  public List intercept(List methods, ITestContext context) {
//    p(methods, "Before");
    Collections.sort(methods, MethodInstance.SORT_BY_INDEX);
//    p(methods, "After");
    return methods;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy