Find mockito-kotlin / Mockito patterns
Recipe ID
org.openrewrite.kotlin.testing.FindMockitoSmells$KtRecipeArtifact
io.moderne.recipe:recipes-kotlinSearch-only bundle covering the Mockito surface most worth reviewing when migrating to mockk: mock/spy allocations, whenever.thenReturn chains, verify(...) calls, argument matchers, ArgumentCaptor.forClass, and @Mock/@InjectMocks field annotations.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.kotlin.testing.FindMockitoSmells$KtRecipeIf the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:recipes-kotlin:0.2.0Definition
This recipe runs the following recipes in order.
- Find
Mockito.mock(...)/mock<X>()callsorg.openrewrite.kotlin.testing.FindMockitoMockCall$KtRecipe - Find
Mockito.spy(...)/spy(...)callsorg.openrewrite.kotlin.testing.FindMockitoSpyCall$KtRecipe - Find Mockito
whenever(...).thenReturn(...)chainsorg.openrewrite.kotlin.testing.FindMockitoWhenThenReturn$KtRecipe - Find Mockito
verify(mock).method(...)callsorg.openrewrite.kotlin.testing.FindMockitoVerifyCall$KtRecipe - Find Mockito argument-matcher
any()/eq()/isA()callsorg.openrewrite.kotlin.testing.FindMockitoArgumentMatchersAny$KtRecipe - Find
ArgumentCaptor.forClass(X::class.java)allocationsorg.openrewrite.kotlin.testing.FindMockitoArgumentCaptor$KtRecipe - Find Mockito
@Mockfieldsorg.openrewrite.kotlin.testing.FindMockitoMockField$KtRecipe - Find Mockito
@InjectMocksfieldsorg.openrewrite.kotlin.testing.FindMockitoInjectMocks$KtRecipe
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats