-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Mockito 2.0.94-beta breaks org.springframework.boot.test.mock.mockito.MockReset #6520
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
We'll need to switch to reflection calls I guess. |
Marking as an enhancement because Mockto 2 isn't officially supported yet. |
Hey, Mockito developer here. Just found out this usage of MockUtil. We would like to discuss possible improvements of our public API to prevent usage of our internal API. Recently we have introduced a listener which can be observed by frameworks to receive some notifications, we might be able to expand this to other usecases as well. Please let us know what we can do :) |
Hi @TimvdLippe, thanks for the offer of help! We currently use |
@TimvdLippe The other places we use it are:
|
@philwebb The mock meta-data seems like an interesting usecase! Are you willing to create an issue on https://github.com/mockito/mockito with a proposed API to make this as easy as possible for a user. We can use that as a starting point to investigate how we can integrate this into the current framework 🎉 Regarding the SpyDefinition, that should not be broken with the static method, only the constructor of MockUtil. Does not really seem like a hack, so I am fine with it. Lastly regarding Spring AOP: I am sorry but I have no experience with Spring or any of its proxies. @marcingrzejszczak are you familiar with this code and maybe know what is going on? |
@TimvdLippe sure thing. See mockito/mockito#539 |
@TimvdLippe @philwebb yeah I can check it out tomorrow |
I think ideally we'd need a first class way to tell if mocking has started and optionally switch out the target. The problem we have is that Spring AOP provides its own proxy which can get in the way. So for example, say you're using
If two calls are made to a
Usually this is fine, but in the case of a |
Is there a workaround for this at the moment? Perhaps a way to disable the automated mock reseting? I'm stuck at the moment between this bug and mockito/mockito#72 . I'm trying to do integration testing in Groovy using injected mocks--see http://stackoverflow.com/questions/39485118/mocking-a-groovy-service-with-spring-boot for a more complete description of the problem I'm running into. |
@mhworth We don't officially support Mockito 2.0 yet. If you need to use it so that you can use Groovy, then I think your best bet at the moment is to not use |
Is there an ETA on this one? It's a shame we can't use the java8 lambda features present in mockito2. |
@agoston No precise ETA. The issue's assigned to 1.5.0.RC1. |
+1 |
1 similar comment
+1 |
How does one disable the MockReset feature? It's crashing my test suite while I never use any MockBean (but I am using the latest version of Mockito). Am I missing something? |
Replying to my own question: The Out of my debugger, the list built by default is the following:
My tests didn't actually need any, so I annotated my test with the following (in Kotlin):
|
@dam5s: I found a workaround without having to remove all execution listeners: #2572 (comment) |
spring-boot-starter-test already contains Junit and Mockito and allows not to use @ContextConfiguration(classes = arrayOf(Kms::class) in each test. When using certain version of Mockito got an error (spring-projects/spring-boot#6520).
I found the workaround after some tries base on comment of @dam5s spring.boot version:1.4.2.RELEASE |
Due to a breaking change in Mockito's internal API it is not possible to execute tests and an IllegalAccessError is thrown (see below)
Formerly Mockito's MockUtils had a public constructor but with this change the class becomes a utility class with no directly accessible constructor. (see mockito/mockito@3fe3b62#diff-321079f7242b016035f4577222dfe7a3R26)
This change breaks org.springframework.boot.test.mock.mockito.MockReset (see https://github.com/spring-projects/spring-boot/blob/master/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockReset.java#L56)
Tested with Spring Boot 1.4.0.RELEASE and mockito-core 2.0.94-beta
The text was updated successfully, but these errors were encountered: