[Mockito] Previous MockitoSession was not concluded with 'finishMocking()'. 에러
2021. 10. 25. 19:13문제
Unfinished mocking session detected.
Previous MockitoSession was not concluded with 'finishMocking()'.
For examples of correct usage see javadoc for MockitoSession class.
org.mockito.exceptions.misusing.UnfinishedMockingSessionException:
Unfinished mocking session detected.
Previous MockitoSession was not concluded with 'finishMocking()'.
For examples of correct usage see javadoc for MockitoSession class.
at com.xxxxx.xxxxxx.xxxxxxxxxxx.setUp(XXXjava:59)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
원인
모킹세션 끝나지 않음.
Unfinished mocking session detected.
해결방법
해결방법 1)
mSession = mockitoSession().startMocking();
mSession.finishMocking();
이 둘을 지워줘야한다.
쓸모없는 mockito세션이 남아있어서 그렇다.
해결방법 2)
@After부분에 Mokcing을 finish 해준다.
mSession.finishMocking();
'Java > Mockito' 카테고리의 다른 글
How to method test (0) | 2021.10.08 |
---|---|
[Mockito] static getInstance() 메서드 mocking하여 테스트 하기 (0) | 2021.10.08 |
[Mockito] void 메서드 mocking 하기. (How to mock void method) (0) | 2021.10.08 |
[Mockito] static method 테스트 (0) | 2021.06.09 |