Skip to content

Raw type used on MockCreationListener changed to generic type#3701

Open
Arsarneq wants to merge 1 commit into
mockito:mainfrom
Arsarneq:arsarneq/issue-3700
Open

Raw type used on MockCreationListener changed to generic type#3701
Arsarneq wants to merge 1 commit into
mockito:mainfrom
Arsarneq:arsarneq/issue-3700

Conversation

@Arsarneq

@Arsarneq Arsarneq commented Aug 6, 2025

Copy link
Copy Markdown

Fixes #3700, so external projects implementing MockCreationListener does no longer get a raw types warning they do not have control over, by using generic type T.
I did see more classes using raw type when using MockCreationSettings class, but this will at least remove the warning from projects using the MockCreationListener.

When using the MockCreationListener implementation should now use generic type, instead of raw type:

public class NoOpTestListener<T> implements MockitoTestListener<T> {

    @Override
    public void testFinished(TestFinishedEvent event) {}

    @Override
    public void onMockCreated(Object mock, MockCreationSettings<T> settings) {}
}

Instead of

public class NoOpTestListener implements MockitoTestListener {

    @Override
    public void testFinished(TestFinishedEvent event) {}

    @Override
    public void onMockCreated(Object mock, MockCreationSettings settings) {}
}

Checklist

  • Read the contributing guide
  • PR should be motivated, i.e. what does it fix, why, and if relevant how
  • If possible / relevant include an example in the description, that could help all readers
    including project members to get a better picture of the change
  • Avoid other runtime dependencies
  • Meaningful commit history ; intention is important please rebase your commit history so that each
    commit is meaningful and help the people that will explore a change in 2 years
  • The pull request follows coding style (run ./gradlew spotlessApply for auto-formatting)
  • Mention Fixes #<issue number> in the description if relevant
  • At least one commit should end with Fixes #<issue number> if relevant

@TimvdLippe

Copy link
Copy Markdown
Contributor

While I do agree we should do this, unfortunately this is a breaking change. Therefore, we would be able to merge this once we get to Mockito 6, although we don't currently have plans to publish a new major version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MockCreationListener uses raw type for generic class MockCreationSettings

2 participants