You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an unusual case with using Mockito and run into an interesting issue, which might be a feature of Java and Mockito or bug, but I wasn't able to figure it out. If it is not a bug, it would be great if you can answer and explain in my SO question.
I have a class with static instance of it and then I create a mock instance in my test, which results that the static instance is not initialized properly. Here relevant parts of the class definition code:
Then the project jar is used in another project where Schema is mocked in a test (Schema is not used before this):
Schemaschema = Mockito.mock(Schema.class);
To my understanding this should not affect the static instance initialization, i.e., Schema.instance. However, I run into an issue that the static instance is not initialized correctly and its properties are null, i.e.:
This is interesting as I have the opposite issue
Using Mockito.mockStatic(Schema.class) will initialize the class, which I don't want since I want to be able to mock static methods before
I have an unusual case with using Mockito and run into an interesting issue, which might be a feature of Java and Mockito or bug, but I wasn't able to figure it out. If it is not a bug, it would be great if you can answer and explain in my SO question.
I have a class with static instance of it and then I create a mock instance in my test, which results that the static instance is not initialized properly. Here relevant parts of the class definition code:
Then the project jar is used in another project where
Schema
is mocked in a test (Schema
is not used before this):To my understanding this should not affect the static instance initialization, i.e.,
Schema.instance
. However, I run into an issue that the static instance is not initialized correctly and its properties arenull
, i.e.:I've found that I can workaround the initialization issue in my test project by loading it explicitly:
Java version: openjdk version "11.0.12" 2021-07-20
Mockito version: 3.5.0
The text was updated successfully, but these errors were encountered: