本文整理汇总了Java中org.testng.IMethodInstance类的典型用法代码示例。如果您正苦于以下问题:Java IMethodInstance类的具体用法?Java IMethodInstance怎么用?Java IMethodInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMethodInstance类属于org.testng包,在下文中一共展示了IMethodInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: byDeclaration
import org.testng.IMethodInstance; //导入依赖的package包/类
public Comparator<IMethodInstance> byDeclaration(){
return new Comparator<IMethodInstance>() {
List<Method> classMethodsInOrder;
@Override
public int compare(IMethodInstance o1, IMethodInstance o2) {
if(classMethodsInOrder == null){
classMethodsInOrder = Stream.of(Reflect.getDeclaredMethodsInOrder(o1.getInstance().getClass())).collect(toList());
}
return Integer.compare(
classMethodsInOrder.indexOf(o1.getMethod().getConstructorOrMethod().getMethod()),
classMethodsInOrder.indexOf((o2.getMethod().getConstructorOrMethod().getMethod()))
);
}
};
}
示例2: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(final List<IMethodInstance> methods, final ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
}
// something else, don't care about the order
return 0;
}
});
return methods;
}
示例3: getGroupOrder
import org.testng.IMethodInstance; //导入依赖的package包/类
private Integer getGroupOrder(IMethodInstance o) {
if (orderedGroups == null) {
return 0;
}
String groupName = (o.getMethod().getGroups() != null) && (o.getMethod().getGroups().length > 0)
? o.getMethod().getGroups()[0] : "NONE";
if (!orderedGroups.contains("NONE")) {
orderedGroups = orderedGroups + ", NONE";
}
if (!orderedGroups.contains(groupName)) {
orderedGroups = orderedGroups + "," + groupName;
}
log.debug(o.getMethod().getMethodName() + " Group: " + groupName + " Order : " + orderedGroups);
return Integer.valueOf(orderedGroups.toUpperCase().indexOf(groupName.toUpperCase()));
}
示例4: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
/**
* This controls the sorting logic of the paxml test case executions.
*/
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> list, ITestContext context) {
List<IMethodInstance> result = new ArrayList<IMethodInstance>(list);
Collections.sort(result, new Comparator<IMethodInstance>() {
@Override
public int compare(IMethodInstance m1, IMethodInstance m2) {
Long pid1 = getPid(m1.getInstances()[0]);
Long pid2 = getPid(m2.getInstances()[0]);
return pid1.compareTo(pid2);
}
});
return result;
}
示例5: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
@Override
public synchronized List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context)
{
/*
* For some unknown reason TestNG calls method interceptors more than once for
* same methods set. We determine if we already seen method by looking at type of internal TestNGMethod field.
*/
List<IMethodInstance> allExpandedMethods = Lists.newArrayList();
for (IMethodInstance method : methods) {
if (isMethodAlreadyExpanded(method)) {
allExpandedMethods.add(method);
}
else {
List<IMethodInstance> newExpandedMethods = expandMethod(method);
incrementSeenMethodsCount(newExpandedMethods);
allExpandedMethods.addAll(newExpandedMethods);
}
}
context.setAttribute(METHODS_COUNT_KEY, seenMethodsCount);
return allExpandedMethods;
}
示例6: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
} else {
// something else, don't care about the order
return 0;
}
}
});
return methods;
}
示例7: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context)
{
if ( !Compatibility.isZK34() )
{
return methods;
}
List<IMethodInstance> filteredMethods = new ArrayList<>();
for ( IMethodInstance method : methods )
{
if ( !isInGroup(method.getMethod().getGroups()) )
{
filteredMethods.add(method);
}
}
return filteredMethods;
}
示例8: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
//Package Name -> Package priority
Comparator<IMethodInstance> compareByPackage = (m1, m2) -> {
String p1 = getPackageName(m1);
String p2 = getPackageName(m2);
return p1.compareTo(p2) - getPackagePriority(p1) + getPackagePriority(p2);
};
//(Package name -> package priority) -> class priority -> class name -> method priority
Comparator<IMethodInstance> comparator = compareByPackage
.thenComparing(m -> getClassPriority(m))
.thenComparing(m -> getClassName(m))
.thenComparing(m -> getMethodPriority(m));
methods.sort(comparator);
return methods;
}
示例9: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods,
ITestContext context) {
List<IMethodInstance> methodsToRun = new ArrayList<IMethodInstance>();
for (IMethodInstance instance : methods) {
String clazz = instance.getMethod().getRealClass().getName();
if (!DriverType.isMobile()) {
if(clazz.endsWith("WebTest")) {
methodsToRun.add(instance);
}
} else {
if(DriverType.isNative() && clazz.endsWith("AppTest")) {
methodsToRun.add(instance);
}
else if(!DriverType.isNative() && clazz.endsWith("MobiTest")){
methodsToRun.add(instance);
}
}
}
return methodsToRun;
}
示例10: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
for (IMethodInstance methodIns : methods) {
ITestNGMethod method = methodIns.getMethod();
ConstructorOrMethod meth = method.getConstructorOrMethod();
Method m = meth.getMethod();
if (m != null) {
DB db = m.getAnnotation(DB.class);
if (db != null) {
TransactionLegacy txn = TransactionLegacy.open(m.getName());
}
}
}
// TODO Auto-generated method stub
return methods;
}
示例11: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
ISuite suite = context.getSuite();
List<IMethodInstance> filtered = new LinkedList<IMethodInstance>();
for (IMethodInstance candidate : methods) {
if (matcher.matchesTest(candidate.getMethod().getTestClass().getName(), candidate.getMethod().getMethodName())
|| matcher.matchesTest(suite.getName(), null)) {
filtered.add(candidate);
}
}
return filtered;
}
示例12: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
/**
* [IMethodInterceptor]
* Invoked to enable alteration of the list of test methods that TestNG is about to run.
*
* @param methods list of test methods.
* @param context test context.
* @return the list of test methods to run.
*/
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
synchronized (methodInterceptors) {
for (IMethodInterceptor interceptor : methodInterceptors) {
methods = interceptor.intercept(methods, context);
}
}
return methods;
}
示例13: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
// target platform support: filter out non-targeted methods
// target platform support: set method target descriptions
return methods;
}
示例14: intercept
import org.testng.IMethodInstance; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
return methods.stream()
.collect(groupingBy(IMethodInstance::getInstance))
.entrySet().stream()
.flatMap(OrderByGroupsListener::orderByGroupsIfListenerIsApplied)
.collect(toList());
}
示例15: orderByGroups
import org.testng.IMethodInstance; //导入依赖的package包/类
private static Stream<IMethodInstance> orderByGroups(Entry<Object, List<IMethodInstance>> entry) {
return entry.getValue().stream()
.collect(groupingBy(method -> asList(method.getMethod().getGroups())))
.entrySet().stream()
.sorted(byGroupOrder())
.flatMap(e -> e.getValue().stream());
}