Mockito keeps intercepting a function I made in a DAO and randomly returning 0. I would like for the function to actually run. Where can I configure this mockito beast to leave the function alone?
Debugger jumps in here instead of going into my spring dao:
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy)
throws Throwable {
if (objectMethodsGuru.isEqualsMethod(method)) {
return proxy == args[0];
} else if (objectMethodsGuru.isHashCodeMethod(method)) {
return hashCodeForMock(proxy);
}
MockitoMethodProxy mockitoMethodProxy = createMockitoMethodProxy(methodProxy);
cglibHacker.setMockitoNamingPolicy(mockitoMethodProxy);
MockitoMethod mockitoMethod = createMockitoMethod(method);
FilteredCGLIBProxyRealMethod realMethod = new FilteredCGLIBProxyRealMethod(mockitoMethodProxy);
Invocation invocation = new Invocation(proxy, mockitoMethod, args, SequenceNumber.next(), realMethod);
return handler.handle(invocation);
}
MockIto (and JMockIt as I took the original question) are mock APIs, they allow developers to write tests which are isolated from the rest of the application or other external resources (such as a database).
As who ever wrote the test decided they do not want this test to hit the database. So they used mockito to prevent this from happening.
Find the developer who wrote this test (or the test you are basing your current test on). Work with them to understand mocking frameworks.