Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't remove mockStatic() calls in resources of try-with-resources #426

Merged
merged 2 commits into from
Nov 20, 2023

Conversation

knutwannheden
Copy link
Contributor

This commit does not yet close the issue, as there are other cases, where this can potentially go wrong.

It also appears strange that the recipe matches on Mockito's mockStatic() rather than on PowerMock's mockStatic(). Therefore, the recipe is for now excluded from Mockito1to3Migration, as this is part of JUnit4to5Migration which is widely used.

Issue: #360

This commit does not yet close the issue, as there are other cases, where this can potentially go wrong.

It also appears strange that the recipe matches on Mockito's `mockStatic()` rather than on PowerMock's `mockStatic()`. Therefore, the recipe is for now excluded from `Mockito1to3Migration`, as this is part of `JUnit4to5Migration` which is widely used.

Issue: #360
@knutwannheden knutwannheden self-assigned this Nov 20, 2023
@timtebeek timtebeek added the bug Something isn't working label Nov 20, 2023
@knutwannheden
Copy link
Contributor Author

@timtebeek We should take a fresh look at this PowerMock recipe. The thing with the mockStatic() matcher looks really odd to me. I also don't understand why the recipe uses a precondition like

Preconditions.or(
new UsesType<>("org.powermock..*", false),
new UsesType<>("org.mockito..*", false)
),

rather than only checking for PowerMock.

@timtebeek
Copy link
Contributor

@timtebeek We should take a fresh look at this PowerMock recipe. The thing with the mockStatic() matcher looks really odd to me. I also don't understand why the recipe uses a precondition like

rather than only checking for PowerMock.

Agree that's odd; would only migrate when there's a confusing mix of libraries in use in a source file already? We can loosen that restriction as part of this PR, especially now that it's not part of the default set of recipes run anymore in larger composed migrations.

@knutwannheden knutwannheden merged commit da6a123 into main Nov 20, 2023
1 check passed
@knutwannheden knutwannheden deleted the powermock-fix branch November 20, 2023 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants