Replace PowerMock usages with Mockito
MSALReplaces the PowerMock API, runners, rules and annotations used in Java sources with their Mockito counterparts, and PowerMock Whitebox with Java reflection. Build files are left unchanged.
org. openrewrite. java. testing. mockito. ReplacePowerMockitoUsagesmod run . --recipe= org. openrewrite. java. testing. mockito. ReplacePowerMockitoUsagesInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.
Recipe list
It runs these recipes, in this order.
- Remove annotation
@org.powermock.core.classloader.annotations.PowerMockIgnore - Remove annotation
@org.powermock.core.classloader.annotations.SuppressStaticInitializationFor - Replace PowerMock runner with JUnit
@RunWith - Replace
PowerMock.mockStatic()withMockito.mockStatic() - Change method target to static
- Replace PowerMockito
doX().when(instance, "method")with Mockito-compatible stubbing - Replace
PowerMockito.doX()withMockito.doX() - Change method target to static
- Change method target to static
- Change method target to static
- Change method target to static
- Change method target to static
- Remove
PowerMockRulefields - Remove PowerMock class extensions
- Remove annotation
@org.powermock.core.classloader.annotations.PrepareForTest - Remove annotation
@org.powermock.core.classloader.annotations.PrepareOnlyThisForTest - Remove annotation
@org.powermock.core.classloader.annotations.PrepareEverythingForTest - Replace
PowerMockito.whenNewwith Mockito counterpart - Replace PowerMock
Whitebox.setInternalState()with@InjectMocks - Replace PowerMock
Whiteboxwith Java reflection - Cleanup PowerMock imports