Skip to content

Retain Mockito Strictness WARN when switching to JUnit 5 through @MockitoSettings(strictness = Strictness.WARN)#584

Merged
timtebeek merged 10 commits intomainfrom
mockito-strictness-default
Aug 21, 2024
Merged

Retain Mockito Strictness WARN when switching to JUnit 5 through @MockitoSettings(strictness = Strictness.WARN)#584
timtebeek merged 10 commits intomainfrom
mockito-strictness-default

Conversation

@Laurens-W
Copy link
Copy Markdown
Contributor

@Laurens-W Laurens-W commented Aug 20, 2024

What's changed?

Add a recipe to add @MockitoSettings(strictness = Strictness.WARN) so that the default behavior does not change

What's your motivation?

When switching from JUnit 4 to JUnit Jupiter the default for strictness changed from WARN to STRICT_STUBS, which could cause previously passing tests to now fail. That's not desirable, we'd rather keep them passing and warning about unnecessary stubs as seen before the migration.

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@Laurens-W Laurens-W added the enhancement New feature or request label Aug 20, 2024
@Laurens-W Laurens-W requested a review from timtebeek August 20, 2024 13:45
@Laurens-W Laurens-W self-assigned this Aug 20, 2024
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment thread src/main/resources/META-INF/rewrite/mockito.yml Outdated
@timtebeek timtebeek marked this pull request as ready for review August 21, 2024 11:31
@timtebeek timtebeek self-requested a review August 21, 2024 11:31
As preconditions only match the exact same file, and there's no guaranteed dependency marker available when visiting compilation units.
@timtebeek timtebeek self-requested a review August 21, 2024 12:20
@timtebeek timtebeek changed the title Retain lenient stubbing behaviour when using Mockito and migration from JUnit 4 to 5 Retain Mockito Strictness WARN when switching to JUnit 5 through @MockitoSettings(strictness = Strictness.WARN) Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants