Upgrade to Mockito 4.x

MSAL

Upgrade Mockito from 1.x to 4.x.

org.openrewrite.java.testing.mockito.Mockito1to4Migration
mod run . --recipe=org.openrewrite.java.testing.mockito.Mockito1to4Migration

Install 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.

  1. Upgrade Mockito from 1.x to 3.x
  2. Replace Mockito.when on static (non mock) with try-with-resource with MockedStatic
  3. Upgrade Gradle or Maven dependency versions org.mockito:*:4.x
  4. Change Gradle or Maven dependency org.mockito:mockito-all
  5. Upgrade Gradle or Maven dependency versions net.bytebuddy:byte-buddy*:1.12.19
  6. Upgrade Byte Buddy along with Mockito 4
  7. Replace MockitoAnnotations.initMocks(this) to MockitoAnnotations.openMocks(this)
  8. Close unclosed static mocks