Repository navigation
Migrate Whitebox and remove PowerMock plumbing when replacing PowerMockito - #1337
Merged
Merged
Conversation
…osing the `MockedStatic`
…to.mockStatic()` type
…lass literal to static field access
… another call or returned from a lambda
… and migrate them to Mockito
# Conflicts: # src/main/resources/META-INF/rewrite/recipes.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changed?
Whitebox.getInternalState/setInternalState/invokeMethod/getField/getMethodnow handle class-literal and static targets, thewhereoverload, varargs, explicit type arguments, returned values and lambdas;Whitebox.getInnerClassTypeis covered too.Whitebox.setInternalState(X.class, ..)used to produce silently wrong code (X.class.getClass()) and no longer does.MockRepository.*,PowerMockAgent.initializeIfNeeded, leftoverPowerMockRunnerandPowerMockObjectFactory(with its TestNG@ObjectFactorymethod) are removed.mockStatictype, such asInet4Address.getByName, are retargeted to the declaring class instead of disabling the test.PowerMock.createMock/createNiceMock/createStrictMock/replay/verifybecomeEasyMockcalls and then go throughEasyMockCodeToMockito.What's your motivation?
A run of
ReplacePowerMockitoover 190 open-source repositories (https://dev.moderne.io/results/ALL/20261118221102-P76NN) disabled 1202 tests in 84 of them.Anything in particular you'd like reviewers to focus on?
Across 12 synced repos, added
@Disabledwent from 15 to 1 (aws-xray-sdk-java 6 to 0, checkstyle-lgtm 9 to 1; the one left relies on private members). TheEasyMockroute leavesMockito.verify(mock);for a verify with no recorded expectations, which compiles, andEasyMockVerifyToMockitoVerifygenerates calls without type attribution, so a test relaxesmethodInvocationsvalidation.System/Threadstatic mocks andverifyPrivatestay flagged. The patched aws-xray-sdk-java was not compiled (errorprone javac jar would not resolve); the mockito test suite passes.Part of a series hardening
ReplacePowerMockito, one PR per family of gaps.