org.mockito.exceptions.misusing.NotAMockException on InjectMocks object
问题 I'm trying to mock the return value from a method but I'm getting NotAMockException . @InjectMocks private MyService myService; @Mock private OtherServiceUsedInMyServiceAsAutowired otherServiceUsedInMyServiceAsAutowired; Inside MyService I have a method called myMethod() and I want to return dummy object when this method is called. doReturn(someDummyObject).when(myService).myMethod(any(), any(), any()); And at that point I'm getting the error. What am I doing wrong? Full error: org.mockito