Skip to content

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

Description

@spelletier

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions