Skip to content

PowerMockMaker with Mockito2 #769

@podarsmarty

Description

@podarsmarty

Until we fully move from CGLIB to Byte Buddy we should let the user choose to not use the PowerMockMaker for certain mocks. This would be extremely helpful for tests that do not require PowerMock to still take advantage of Mockito2 features such as mocking public methods of a non-public parent class while still allowing tests in the project to leverage PowerMock.

I think we should use implement a mockito PluginSwitch which allows the user to turn off/on the PowerMockMaker plugin temporarily. This, however, is not currently possible as we are unable to tell mockito to reload plugins after the PluginSwitch updates state due to the registry being final. Will update with mockito ticket (edit: mockito/mockito#1003). While this is not done yet, we can work around it by putting this switch inside of PowerMockMaker.

What steps will reproduce the problem?

  • Try to mock out a public method in a non-public parent class.
    What is the expected output?
  • Method to be mocked.
    What do you see instead?
  • mockito exception due to PowerMockMaker still using cglib.
    What version of the product are you using?
  • 1.7.0RC4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions