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
Obscure issue with mockito-inline: mock object in a test seems to be corrupting mock in later test #2499
Comments
PR for fix is open. |
thx @raphw! |
hi @raphw do you have any indicative dates on when this bug would be released? or if its available in some other build I can try out |
@TimvdLippe Any reason not to trigger a release some time soon? |
It's been about a month since we last released, so I will release one today. Thanks! |
I'll do a BB release later today. It contains some Java 17 bug fixes, so you might just wait on that. |
Ha. I just started the release procedure, but I canceled the GitHub action again. Will wait for the BB release 👍 |
many thanks! |
Central is timeouting a lot since everybody tries to fix their log4shell issues. Let's delay a few days. |
I updated our version of BB and starting a new release now. |
4.2.0 is being published to Maven Central atm: https://github.com/mockito/mockito/actions/runs/1587549926 |
This is a very obscure issue, happens only when the planets are aligned. Can you possibly tell me if this is an issue with mockito-inline or if I'm doing something wrong. If its an issue, is there a workaround?
I've simplified what I'm seeing as much as possible. I have 2 tests: Test1 and Test2. I mock MyClass in Test1 (calling clearInlineMocks in @afterclass). In Test2, I mock TestSubInterface which extends TestInterface, which creates an instance of the class I mocked in Test1. The issue is that the constructor for MyClass is not being called when mocking the TestSubInterface in Test2 (I guess because mockito-inline still sees MyClass as a mock from the previous test?). I initialize a variable in the MyClass constructor and later throw an error if it hasn't been initialized, resulting in a java.lang.NoClassDefFoundError when mocking.
HOWEVER, the constructor for MyClass IS called when:
Here are the details:
I'm on windows 10
java --version
java 17.0.1 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)
check that
Note that some configuration are impossible to mock via Mockito
(same as any question on stackoverflow.com)
The text was updated successfully, but these errors were encountered: