-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Mockito fails to verify mocked @Service when service contains @Retryable methods #6828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could you please give the latest SNAPSHOT version a quick try as we've recently fixed a number of very similar issues. |
How recent? I tried 1.41.SNAPSHOT today
|
1.41.BUILD-SNAPSHOT that is |
That's the most recent. Thanks for giving it a go. |
Looks like the build's broken so the latest snapshot is stale. Something to do with the Bamboo upgrade? |
I don't think there's much we can do automatically when the @ActiveProfiles("Test")
@ContextConfiguration(classes = { SampleBatchApplication.class }, loader = AnnotationConfigContextLoader.class)
@RunWith(SpringRunner.class)
public class MockBatchTestWithRetryVerificationFailures {
@MockBean
MyRetryService service;
@Test
public void batchTest() {
service.process();
verify(service).process();
validateMockitoUsage();
}
} |
Thanks, Phil, you're right, I have a helper method to unwrap aop, so I'll just use that for the moment, it's not too bad. |
@pearj, there's no need to maintain your own helper method for that. See |
@sbrannen thanks for that, although, it seems the generics in that method doesn't agree with eclipse (Eclipse Neon and Java 7), and it thinks the type is of type The signature is: public static <T> T getTargetObject(Object candidate) But I think it should be public static <T> T getTargetObject(T candidate) That way you can use it inline with Otherwise it seems you have to do this: ((MyAopWrappedBean)verify(AopTestUtils.getTargetObject(mybean))).theMethod(); instead of just verify(AopTestUtils.getTargetObject(mybean)).theMethod(); |
I'm using
spring-boot 1.4.0.FINAL
and I'm having trouble when I have a mocked@Service
which has@Retryable
annotations in the class. When I callMockito.verify()
I get anUnfinishedVerificationException
exception:This looks very similar to #5837, in fact, I managed to hack to workaround based off that issue:
See:
sample.batch.MockBatchTestWithRetryVerificationFailuresWorkaround.batchTest()
I have put an example project together here that reproduces this issue: https://github.com/pearj/spring-boot-batch-retry-issue
For the failure case see:
sample.batch.MockBatchTestWithRetryVerificationFailures.batchTest()
Is it possible for a transparent fix somehow?
I also have this on stackoverflow
The text was updated successfully, but these errors were encountered: