Skip to content
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

Support spying on final classes #16665

Conversation

cvienot
Copy link

@cvienot cvienot commented Apr 26, 2019

Closes gh-7033

We currently cannot spy on spring data repositories because the proxy are finals.
We can work around this limitation by using mockito inline-mocker-maker plugin.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 26, 2019
@wilkinsona
Copy link
Member

wilkinsona commented Apr 26, 2019

Thanks for the suggestion but I don't think we should opt everyone in to Mockito's support for mocking final classes. It's still marked as an incubating feature and the Mockito release notes have this to say about it:

Mocking of final classes and methods is an incubating, opt-in feature. It uses a combination of Java agent instrumentation and subclassing in order to enable mockability of these types. As this works differently to our current mechanism and this one has different limitations and as we want to gather experience and user feedback, this feature had to be explicitly activated to be available

I believe that you can opt in to the new mechanism and its different limitations by adding the org.mockito.plugins.MockMaker metadata to your own application in src/test/resources.

@wilkinsona wilkinsona closed this Apr 26, 2019
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@SpyBean does not work when used to spy on a Spring Data Repository
3 participants