Package org.openrewrite.test
Interface RewriteTest
- All Superinterfaces:
Iterable<SourceSpec<?>>,SourceSpecs
-
Field Summary
FieldsModifier and TypeFieldDescriptionRegistry of customizers applied to theExecutionContextproduced bydefaultExecutionContext(SourceSpec[]). -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertContentEquals(org.openrewrite.SourceFile sourceFile, String expected, String actual, String errorMessagePrefix) default voidCheck that all recipes loadable from the runtime classpath containing the test's package are configurable and run with an empty source file set.default voidassertRecipesConfigure(String packageName) Check that all recipes loadable from the runtime classpath containing the provided package name are configurable and run with an empty source file set.default org.openrewrite.ExecutionContextdefaultExecutionContext(SourceSpec<?>[] sourceSpecs) default voiddefaults(RecipeSpec spec) default @Nullable Stringstatic org.openrewrite.RecipefromRuntimeClasspath(String recipe) default Iterator<SourceSpec<?>> iterator()default voidrewriteRun(Consumer<RecipeSpec> spec, SourceSpec<?>... sourceSpecs) default voidrewriteRun(Consumer<RecipeSpec> spec, SourceSpecs... sourceSpecs) default voidrewriteRun(SourceSpec<?>... sources) default voidrewriteRun(SourceSpecs... sourceSpecs) default RewriteRunnerrunner()Class-level defaultRewriteRunner.static AdHocRecipetoRecipe()static AdHocRecipetoRecipe(Function<org.openrewrite.Recipe, org.openrewrite.TreeVisitor<?, org.openrewrite.ExecutionContext>> visitor) static AdHocRecipedefault voidvalidateRecipeNameAndDescription(org.openrewrite.Recipe recipe) default voidvalidateRecipeOptions(org.openrewrite.Recipe recipe) Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
defaultExecutionContextCustomizers
static final Map<Class<?>,Consumer<org.openrewrite.ExecutionContext>> defaultExecutionContextCustomizersRegistry of customizers applied to theExecutionContextproduced bydefaultExecutionContext(SourceSpec[]). Test framework integrations (e.g. a JUnit JupiterBeforeAllCallback) can register a customizer once at startup withoutrewrite-testtaking a dependency on the framework.The map is keyed by the integration's class so
putIfAbsent(MyExt.class, MyExt::load)is naturally idempotent — callers do not need their own one-shot guard.
-
-
Method Details
-
toRecipe
static AdHocRecipe toRecipe(Supplier<org.openrewrite.TreeVisitor<?, org.openrewrite.ExecutionContext>> visitor) -
toRecipe
-
toRecipe
static AdHocRecipe toRecipe(Function<org.openrewrite.Recipe, org.openrewrite.TreeVisitor<?, org.openrewrite.ExecutionContext>> visitor) -
fromRuntimeClasspath
-
assertRecipesConfigure
Check that all recipes loadable from the runtime classpath containing the provided package name are configurable and run with an empty source file set.- Parameters:
packageName- The package name to scan for recipes in.
-
assertRecipesConfigure
default void assertRecipesConfigure()Check that all recipes loadable from the runtime classpath containing the test's package are configurable and run with an empty source file set. -
doesNotExist
- Returns:
- always null, a method that better documents in code that a source file does not exist either before or after a recipe run.
-
defaults
-
runner
Class-level defaultRewriteRunner. Override (or via@ExtendWith) to run everyrewriteRuncall in this class through a non-default backend — typically a moderne-cli runner that stages the test's sources to a temp dir, invokes the CLI, and translates the result back into aRecipeRun. Per-call overrides viaRecipeSpec.runner(RewriteRunner)take precedence. -
rewriteRun
-
rewriteRun
-
rewriteRun
-
assertContentEquals
-
rewriteRun
-
defaultExecutionContext
-
iterator
- Specified by:
iteratorin interfaceIterable<SourceSpec<?>>
-
validateRecipeNameAndDescription
default void validateRecipeNameAndDescription(org.openrewrite.Recipe recipe) -
validateRecipeOptions
default void validateRecipeOptions(org.openrewrite.Recipe recipe)
-