Recipe testing best practices
Recipe ID
org.openrewrite.java.recipes.RecipeTestingBestPracticesArtifact
org.openrewrite.recipe:rewrite-rewriteBest practices for testing recipes.
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.java.recipes.RecipeTestingBestPracticesIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-rewrite:0.29.0Definition
This recipe runs the following recipes in order.
- Replace
Stream.collect(Collectors.toUnmodifiableList())withStream.toList()org.openrewrite.java.migrate.util.ReplaceStreamCollectWithToList - RewriteTest classes should not be public
org.openrewrite.java.recipes.RewriteTestClassesShouldNotBePublic - Automatically select recipe examples from the unit test cases of a recipe
org.openrewrite.java.recipes.SelectRecipeExamples - Single
@DocumentExampleper test classorg.openrewrite.java.recipes.SingleDocumentExample - Show
@DocumentExamples firstorg.openrewrite.java.recipes.ReorderTestMethods - Replace null with RewriteTest.doesNotExist()
org.openrewrite.java.recipes.ReplaceNullWithDoesNotExist - New line at the end of
SourceSpecstext blocksorg.openrewrite.java.recipes.SourceSpecTextBlockNewLine - Minimal indentation for
SourceSpecstext blocksorg.openrewrite.java.recipes.SourceSpecTextBlockIndentation - Refactor RewriteTest to use defaults method
org.openrewrite.java.recipes.UseRewriteTestDefaults - Use
StringUtilsutility methodsorg.openrewrite.java.recipes.UseStringUtilsRecipes - Use
varfor variables initialized with type castsorg.openrewrite.java.migrate.lang.var.UseVarForTypeCast - Use
varfor constructor call assignmentsorg.openrewrite.java.migrate.lang.var.UseVarForConstructors - Apply
varto Generic Constructorsorg.openrewrite.java.migrate.lang.var.UseVarForGenericsConstructors - Apply
varto generic method invocationsorg.openrewrite.java.migrate.lang.var.UseVarForGenericMethodInvocations - Use
varfor primitive and String variablesorg.openrewrite.java.migrate.lang.var.UseVarForPrimitive - Use modernized
java.utilAPIsorg.openrewrite.java.migrate.util.JavaUtilAPIs - Convert Javadoc to Markdown documentation comments
org.openrewrite.java.migrate.lang.JavadocToMarkdownDocComment - JUnit 6 best practices
org.openrewrite.java.testing.junit.JUnit6BestPractices - AssertJ best practices
org.openrewrite.java.testing.assertj.Assertj - Fix missing braces
org.openrewrite.staticanalysis.NeedBraces - Remove
System.out#printlnstatementsorg.openrewrite.staticanalysis.RemoveSystemOutPrintln - Reorder annotations alphabetically
org.openrewrite.staticanalysis.ReorderAnnotations - Use static import
org.openrewrite.java.UseStaticImport - Use static import
org.openrewrite.java.UseStaticImport - Use static import
org.openrewrite.java.UseStaticImport - Change method target to static
org.openrewrite.java.ChangeMethodTargetToStatic - Change method name
org.openrewrite.java.ChangeMethodName
Data tables
Structured output this recipe can produce.
- Maven metadata failuresAttempts to resolve maven metadata that failed.
org.openrewrite.maven.table.MavenMetadataFailures - 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