private IMethodInstance mockIMethodAnnotatedWith(Class methodClass, boolean firstTestAnnotation,
boolean lastTestAnnotation, boolean orderAnnotation) throws Exception {
IMethodInstance methodInstance = mock(IMethodInstance.class);
ITestNGMethod testNgMethod = mock(ITestNGMethod.class);
when(methodInstance.getMethod()).thenReturn(testNgMethod);
when(testNgMethod.getRealClass()).thenReturn(methodClass);
String methodName;
if (firstTestAnnotation && lastTestAnnotation && orderAnnotation == true) {
methodName = ClassWithMethodsToTest.WITH_TEST_ORDER_ONE_AND_FIRST_AND_LAST_ANNOTATION;
} else if (firstTestAnnotation && lastTestAnnotation && orderAnnotation == false) {
methodName = ClassWithMethodsToTest.WITH_FIRST_AND_LAST_ANNOTATION;
} else if (firstTestAnnotation && orderAnnotation == true) {
methodName = ClassWithMethodsToTest.WITH_TEST_ORDER_ONE_AND_FIRST_TEST;
}
else if (firstTestAnnotation && orderAnnotation == false) {
methodName = ClassWithMethodsToTest.WITH_FIRST_TEST_ANNOTATION;
}
else if (lastTestAnnotation && orderAnnotation == true) {
methodName = ClassWithMethodsToTest.WITH_TEST_ORDER_ONE_AND_LAST_TEST;
}
else if (lastTestAnnotation && orderAnnotation == false) {
methodName = ClassWithMethodsToTest.WITH_LAST_TEST_ANNOTATION;
}
else if(orderAnnotation == true) {
methodName = ClassWithMethodsToTest.WITH_TEST_ORDER_ONE;
}
else {
methodName = ClassWithMethodsToTest.WITHOUT_ANNOTATIONS;
}
mockWithMethod(testNgMethod, methodName);
when(testNgMethod.getMethodsDependedUpon()).thenReturn(new String[]{});
return methodInstance;
}