Issue #41 new

Mockito says "is not a mock" on mocks created with @Autowired by springockito

Anonymous created an issue

Problem appeared after commit c20392d.

Here it is, how mockito check, that object is Mockito Mock. In org.mockito.internal.util.MockUtil:

    private <T> boolean isMockitoMock(T mock) {
        return mockMaker.getHandler(mock) != null;
    }

In org.mockito.internal.creation.CglibMockMaker exist function getHandler(Object Mock):

    public MockHandler getHandler(Object mock) {
        ...
        Callback callback = factory.getCallback(0);
        if (!(callback instanceof MethodInterceptorFilter)) {
            return null;
        }
        ...
    }

Because after this commit callback is ThreadLocalMockMethodInterceptor, this check fails. So you can't use verify on Mock created with @Atowired by springockito.