Upgrade Mockito from 1.x to 3.x
MSALUpgrade Mockito from 1.x to 3.x.
org. openrewrite. java. testing. mockito. Mockito1to3Migrationmod run . --recipe= org. openrewrite. java. testing. mockito. Mockito1to3MigrationInstall 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.
- Change type
org.mockito.MockitoAnnotations.Mocktoorg.mockito.Mock - Replace Mockito 1.x
anyString()/any()withnullable(Class) - Change type
MatcherstoArgumentMatchers - Convert
ArgumentMatcher<T>anonymous class to lambda - Change method name
org.mockito.* anyVararg()toany - Change method name
org.mockito.* anyObject()toany - Delete method argument 0 in methods
org.mockito.* anyListOf(java.lang.Class) - Change method name
org.mockito.* anyListOf()toanyList - Delete method argument 0 in methods
org.mockito.* anySetOf(java.lang.Class) - Change method name
org.mockito.* anySetOf()toanySet - Delete method argument 0 in methods
org.mockito.* anyMapOf(java.lang.Class, java.lang.Class) - Delete method argument 0 in methods
org.mockito.* anyMapOf(java.lang.Class) - Change method name
org.mockito.* anyMapOf()toanyMap - Delete method argument 0 in methods
org.mockito.* anyCollectionOf(java.lang.Class) - Change method name
org.mockito.* anyCollectionOf()toanyCollection - Delete method argument 0 in methods
org.mockito.* anyIterableOf(java.lang.Class) - Change method name
org.mockito.* anyIterableOf()toanyIterable - Delete method argument 0 in methods
org.mockito.* isNull(java.lang.Class) - Delete method argument 0 in methods
org.mockito.* notNull(java.lang.Class) - Reorder method arguments
- Replace
verifyZeroInteractions()withverifyNoMoreInteractions() - Change method name
org.mockito.Mockito verifyZeroInteractions(..)toverifyNoInteractions - Change method name
org.mockito.invocation.InvocationOnMock getArgumentAt(int, java.lang.Class)togetArgument - Change type
TooLittleActualInvocationstoTooFewActualInvocations - Change type
org.mockito.configuration.AnnotationEnginetoorg.mockito.plugins.AnnotationEngine - Change type
InstantiatorProvidertoInstantiatorProvider2 - Change type
org.mockito.runners.MockitoJUnitRunnertoorg.mockito.junit.MockitoJUnitRunner - Replace undeclared checked exceptions in
thenThrowwithRuntimeException - Cleanup Mockito imports
- Use static form of Mockito
MockUtil - Replace PowerMock with raw Mockito
- JUnit 4
MockitoJUnitto JUnit JupiterMockitoExtension - Add
@MockitoSettings(strictness = Strictness.WARN)for legacy Mockito modules - Replace
MockitoTestExecutionListener(JUnit Jupiter projects) - Replace
MockitoTestExecutionListener(JUnit 4 projects) - Replace
MockitoTestExecutionListener(TestNG projects) - Remove
MockitoAnnotations.initMocks(this)andopenMocks(this)if JUnit runners specified - Remove
doNothing()for void methods on@Mockfields - Change Gradle or Maven dependency
org.mockito:mockito-all - Upgrade Gradle or Maven dependency versions
org.mockito:*:3.x - Change Gradle or Maven dependency
org.mockito:mockito-all - Upgrade Gradle or Maven dependency versions
net.bytebuddy:byte-buddy*:1.11.13 - Upgrade Byte Buddy along with Mockito 3