-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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 Mockito with @MockBean and @SpyBean in AOT-processed tests #32195
Comments
Add a guard for `ResetMocksTestExecutionListener` so that it is not applied when running in a native image. See gh-32195
FYI there is ongoing work on GraalVM side to make it work, I will try to share up to date news about current status. |
There's more than just GraalVM supporting this. Currently, using |
We have a smoke test which uses |
I've added metadata for Mockito 4.8.1 to the reachability-metadata repository. However I found no way to get the class mocks from Mockito working, as they all rely on creating classes at runtime. But it works when using the |
@mhalbritter are there plans to support @MockBean? Having this with the proxymockmaker would be already a big gain. |
Indeed, that would be really great. Hopefully we get this working with Boot 3.1. |
Following spring-projects/spring-framework#31705 (comment) and spring-projects/spring-boot#32195, there is an incompatibility with AOTProcess of tests. For this reason we remove the native plugin.
Various users (example here) seems confused about seeing their unit tests broken when using just the AOT plugin, without using GraalVM native images support. My proposal would either to:
Since I am not sure we should do something specific for Mockito on native side (should be handled on GraalVM side), I would maybe favor turning this issue into fixing the AOT support, and see later if a dedicated native issue is needed, but of course up to the Boot team to decide. |
Thanks, @sdeleuze. I've updated the issue's title to focus on the AOT side of things. Once that has been addressed we can consider what's left for general native support of Mockito. |
If just found with updating to 3.2 that @DisabledInAotMode did break my native tests. I had to use @DisabledInNativeTest and ignore the aot errors to make the native tests work again. There was an issue with some AotDetector beeing initialized at compile time when trying to run the native tests if I remember correctly. Should that be a seperate issue? |
@eiswind That's a known issue in Spring Framework: spring-projects/spring-framework#31705 |
@wilkinsona As always: Thanks for pointing me there. |
@bclozel another one for Framework please to consider as an enhancement (if it's not already supported) to |
Thanks, @sbrannen. |
For anyone interested in this issue, please note that Spring Framework 6.2 will support the use of However, as stated in the commit, |
Currently Mockito doesn't work with native tests. See spring-attic/spring-native#1561 and spring-attic/spring-native#1063 for more details.
For now, we can disable the
ResetMocksTestExecutionListener
, but it would be nice if we could make Mockito work.The text was updated successfully, but these errors were encountered: