-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Issue with Mockito and JpaRepository #12467
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
Thanks for the sample, @YLombardi. This looks like a bug to me. I'd expect your @WebMvcTest(ControllerA.class) |
The main application class has a |
Thanks, @bclozel. I was wondering why our tests for this were passing and hadn't spotted that difference . I wonder if there's something we can do to at least make it obvious that the use of Either way, I think we should update the javadoc as it currently says that |
Now that I know what's going on, this is a duplicate of #10933. |
Thanks for your answers. |
Hello,
I don't know if this an issue with Spring boot data JPA or with Mockito but I encountered a strange behaviour.
I create 2 Controller. In the first, I inject a Service. In the second, I inject a JpaRepository.
Now I create UnitTests for both this Controller.
For the second Controller, I mock the Repository. Everything works fine.
For the first Controller, I mock the Service. The test fail.
It seems to search to inject the Repository whereas it is not used in this Controller.
I create a very simple project to reproduce this behavior :
https://github.com/YLombardi/mockito-spring-jpa-issue
Is it my test that is wrong or a bug ?
The text was updated successfully, but these errors were encountered: