You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently using the Mock resolver plugin feature (#2042) in my projects, but verify() on a wrapped mock does not work as expected and throws a UnfinishedVerificationException.
A junit5 test case to reproduce this bug is already in the extTest module: MockResolverTest but it is not executed by default.
After adding the junitJupiterEngine as test runtime, the MockResolverTest is executed, but fails with following message:
Missing method call for verify(mock) here:
-> at org.mockitousage.plugins.resolver.MockResolverTest$MockWrapper.doIt(MockResolverTest.java:47)
Example of correct verification:
verify(mock).doSomething()
Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.
Mocking methods declared on non-public parent classes is not supported.
org.mockito.exceptions.misusing.UnfinishedVerificationException:
Missing method call for verify(mock) here:
-> at org.mockitousage.plugins.resolver.MockResolverTest$MockWrapper.doIt(MockResolverTest.java:47)
Example of correct verification:
verify(mock).doSomething()
Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.
Mocking methods declared on non-public parent classes is not supported.
at org.mockito.internal.exceptions.Reporter.unfinishedVerificationException(Reporter.java:115)
at org.mockito.internal.progress.MockingProgressImpl.validateMostStuff(MockingProgressImpl.java:124)
at org.mockito.internal.progress.MockingProgressImpl.validateState(MockingProgressImpl.java:105)
at org.mockito.internal.MockitoCore.validateMockitoUsage(MockitoCore.java:248)
at org.mockito.Mockito.validateMockitoUsage(Mockito.java:3248)
at org.mockito.internal.framework.DefaultMockitoSession.finishMocking(DefaultMockitoSession.java:93)
at org.mockito.junit.jupiter.MockitoExtension.afterEach(MockitoExtension.java:186)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterEachCallbacks$11(TestMethodTestDescriptor.java:253)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$12(TestMethodTestDescriptor.java:269)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
...
The reason why failing is a missing MockUtil.resolve() before the identity check here:
I am currently using the Mock resolver plugin feature (#2042) in my projects, but verify() on a wrapped mock does not work as expected and throws a UnfinishedVerificationException.
A junit5 test case to reproduce this bug is already in the extTest module: MockResolverTest but it is not executed by default.
mockito/subprojects/extTest/src/test/java/org/mockitousage/plugins/resolver/MockResolverTest.java
Lines 20 to 27 in 3fe4a18
After adding the junitJupiterEngine as test runtime, the MockResolverTest is executed, but fails with following message:
The reason why failing is a missing MockUtil.resolve() before the identity check here:
mockito/src/main/java/org/mockito/internal/handler/MockHandlerImpl.java
Line 68 in 191c0c0
I will provide a PR to fix this issue.
The text was updated successfully, but these errors were encountered: