Skip to content
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

Spy and Mock of EO, dummies or other WO classes does not works under Mockito 5.x #60

Open
spelletier opened this issue Jun 24, 2024 · 1 comment

Comments

@spelletier
Copy link

By default Mockito 5.x use a new MockMaker that is not compatible with any WO subclasses. It is still possible to create mock and spy by specifying the old MockMaker like this:

  • Replacing @mock with @mock(mockMaker = MockMakers.SUBCLASS) in field declaration;
  • Replacing mock(...) with mock(..., withSettings().mockMaker(MockMakers.SUBCLASS));
  • Replacing spy(instance) with instance = mock(InstanceClass.class, withSettings()
    .mockMaker(MockMakers.SUBCLASS)
    .spiedInstance(instance).defaultAnswer(CALLS_REAL_METHODS));

I suggest to adjust the wounits behaviour when detecting @SPY annotation to specify the old MockMaker and creating a new @EOMock (or WOMock) annotation to help creating compatible mock with the old MockMaker.

@spelletier
Copy link
Author

I have a local working version with the @SPY fix but the MockMakers is new and require Mockito 4.8.

I experience no problems using Mockito 4.x. Maybe we can upgrade the Mockito dependency to 4.8 and adjust code to be compatible with 5.x.

I has to adjust some test code to remove warnings and some error, especially in assert call that changed style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant