Skip to content

Make MockUtil.getMockMaker() public or public Mockito API #3128

@AndreasTu

Description

@AndreasTu

Proposal:

Make the method org.mockito.internal.util.MockUtil.getMockMaker(String) public or better part of the public Mockito Plugin-API.
The existing org.mockito.plugins.MockitoPlugins.getInlineMockMaker() creates a new mock-maker-inline instance when called.

Reason:

I am currently working on a PR for Spock, which integrates Mockito as a Mocking library into Spock for normal and static mocks.

If I use the public API of MockitoPlugins.getInlineMockMaker(), the combination of Mockito and Spock with Mockito leads to strange behavior. E.g. If someone mocks the same static class with Mockito and Spock, the mock-maker-inline gets confused.
The reasons for that is, that two Mockito InlineDelegateByteBuddyMockMaker instances try to transform static methods at the same time.

If I use the MockUtil.getMockMaker() Spock with Mockito and Mockito will interop nicely with each other and report an error, if the same class is mocked twice.
So the user can use Mockito-API in Spock-Tests and also Spock-API, which uses Mockito under the hood.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions