Interface RewriteTest

All Superinterfaces:
Iterable<SourceSpec<?>>, SourceSpecs

public interface RewriteTest extends SourceSpecs
  • Field Details

    • defaultExecutionContextCustomizers

      static final Map<Class<?>,Consumer<org.openrewrite.ExecutionContext>> defaultExecutionContextCustomizers
      Registry of customizers applied to the ExecutionContext produced by defaultExecutionContext(SourceSpec[]). Test framework integrations (e.g. a JUnit Jupiter BeforeAllCallback) can register a customizer once at startup without rewrite-test taking 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

      static AdHocRecipe toRecipe()
    • toRecipe

      static AdHocRecipe toRecipe(Function<org.openrewrite.Recipe,org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext>> visitor)
    • fromRuntimeClasspath

      static org.openrewrite.Recipe fromRuntimeClasspath(String recipe)
    • assertRecipesConfigure

      default void assertRecipesConfigure(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.
      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

      default @Nullable String 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

      default void defaults(RecipeSpec spec)
    • runner

      default RewriteRunner runner()
      Class-level default RewriteRunner. Override (or via @ExtendWith) to run every rewriteRun call 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 a RecipeRun. Per-call overrides via RecipeSpec.runner(RewriteRunner) take precedence.
    • rewriteRun

      default void rewriteRun(SourceSpecs... sourceSpecs)
    • rewriteRun

      default void rewriteRun(Consumer<RecipeSpec> spec, SourceSpecs... sourceSpecs)
    • rewriteRun

      default void rewriteRun(Consumer<RecipeSpec> spec, SourceSpec<?>... sourceSpecs)
    • assertContentEquals

      static void assertContentEquals(org.openrewrite.SourceFile sourceFile, String expected, String actual, String errorMessagePrefix)
    • rewriteRun

      default void rewriteRun(SourceSpec<?>... sources)
    • defaultExecutionContext

      default org.openrewrite.ExecutionContext defaultExecutionContext(SourceSpec<?>[] sourceSpecs)
    • iterator

      default Iterator<SourceSpec<?>> iterator()
      Specified by:
      iterator in interface Iterable<SourceSpec<?>>
    • validateRecipeNameAndDescription

      default void validateRecipeNameAndDescription(org.openrewrite.Recipe recipe)
    • validateRecipeOptions

      default void validateRecipeOptions(org.openrewrite.Recipe recipe)