Mockito 및 Spring Test 프레임 워크를 사용하는 매우 간단한 테스트 케이스가 있습니다. 내가 할 때Mockito Exception -()에 모의 메소드 호출이되어야하는 인수가 필요한 경우
when(pcUserService.read("1")).thenReturn(pcUser);
이 예외가 발생합니다.
org.mockito.exceptions.misusing.MissingMethodInvocationException:
when() requires an argument which has to be 'a method call on a mock'.
For example:
when(mock.getArticles()).thenReturn(articles);
Also, this error might show up because:
1. you stub either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.
2. inside when() you don't call method on mock but on some other object.
at com.project.cleaner.controller.test.PcUserControllerTest.shouldGetPcUser(PcUserControllerTest.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
다른 방법으로 시도했지만이 오류 메시지가 계속 표시됩니다. Mockito와 Spring 3.1.0.RELEASE를 사용하고 있습니다. 나와 공유하고 올바른 방향으로 인도하십시오.
저도 같은 문제를했습니다,하지만 난 사용하고 있습니다 @Autowired @ReplaceWithMock (beanName에 = "logDao") 개인 LogDao logDaoMock을; –