public class PriorityInterceptor implements IMethodInterceptor {
@Override public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) { Comparator<IMethodInstance> comparator = new Comparator<IMethodInstance>() {
private int getPriority(IMethodInstance mi) { int result = 0; int methodPrio = 0; int classPrio = 0; //Method method = mi.getMethod().getMethod(); Method method = mi.getMethod().getConstructorOrMethod().getMethod(); System.out.println("Testsd" + mi + "en" + method); Priority methodPriority = method.getAnnotation(Priority.class); System.out.println("Testsd" + methodPriority); Class<?> cls = method.getDeclaringClass(); Priority classPriority = cls.getAnnotation(Priority.class);
if (methodPriority != null) { methodPrio = methodPriority.value(); classPrio = classPriority.value();
result = Integer.valueOf(String.valueOf(classPrio) + String.valueOf(methodPrio)); System.out.println("IfResult" + result);
} else {
if (classPriority != null) { classPrio = classPriority.value(); result = Integer.valueOf(String.valueOf(classPrio) + "0"); System.out.println("ElseResult" + result); } } return result; }
public int compare(IMethodInstance m1, IMethodInstance m2) { return getPriority(m1) - getPriority(m2); }
}; System.out.println(methods); IMethodInstance[] array = methods.toArray(new IMethodInstance[methods.size()]); System.out.println("lijst1" + Arrays.asList(array)); Arrays.sort(array, comparator); System.out.println("lijst2" + Arrays.asList(array));
return Arrays.asList(array); }
Dwight,
You have only shared how your interceptor looks like.
Can you please also share the following?
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
Reply-To: <testng...@googlegroups.com>
Date: Tuesday, March 6, 2018 at 3:48 AM
To: testng-users <testng...@googlegroups.com>
Subject: [testng-users] ImethodInterceptor not respected when using testgroup only
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
@Priority(1)public class Login extends BaseScenario{ @BeforeMethod(alwaysRun = true) public void setup() { ..... }
@Priority(3) @Test(description = "....", groups = "Regression") public void testLogin() { .... }
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)@Target({ElementType.METHOD, ElementType.TYPE})public @interface Priority { int value() default 0;}
Dwight,
How about you sharing a full-fledged test sample (with just some sysouts), that I can use to reproduce the problem?
I am hoping that the sample would contain the following:
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
Reply-To: <testng...@googlegroups.com>
Date: Tuesday, March 6, 2018 at 1:44 PM
To: testng-users <testng...@googlegroups.com>
Subject: Re: [testng-users] ImethodInterceptor not respected when using testgroup only
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.