Class ParameterizedRunnerToParameterized


  • public class ParameterizedRunnerToParameterized
    extends org.openrewrite.Recipe
    Recipe for migrating JUnit4 @RunWith(Parameterized.class) tests to the JUnit 5 Jupiter ParameterizedTest equivalents.

    1. Remove `@RunWith(Parameterized.class)` 2. Replace `@Test` with `@ParameterizedTest` having arguments from `@Parameters` method 3. Add `@MethodSource(...)` with methodName argument equal to `@Parameters` method name to each `@ParameterizedTest` 4. For constructor injected tests change constructor to an initialization method having a void return type. 5. For field injected test generate and insert an init-method for class field values 6. Remove @Parameters and @Parameter annotations 7. Remove imports org.junit.Test; org.junit.runner.RunWith; org.junit.runners.Parameterized; org.junit.runners.Parameterized.Parameter; org.junit.runners.Parameterized.Parameters; 8. Add imports org.junit.jupiter.params.ParameterizedTest; org.junit.jupiter.params.provider.MethodSource;

    • Field Summary

      • Fields inherited from class org.openrewrite.Recipe

        NOOP
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected @Nullable org.openrewrite.TreeVisitor<?,​org.openrewrite.ExecutionContext> getApplicableTest()  
      java.lang.String getDescription()  
      java.lang.String getDisplayName()  
      protected org.openrewrite.TreeVisitor<?,​org.openrewrite.ExecutionContext> getVisitor()  
      • Methods inherited from class org.openrewrite.Recipe

        causesAnotherCycle, doNext, equals, getDescriptor, getJacksonPolymorphicTypeTag, getLanguages, getName, getRecipeList, getTags, hashCode, run, run, run, run, validate, validate, validateAll, validateAll, visit
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ParameterizedRunnerToParameterized

        public ParameterizedRunnerToParameterized()
    • Method Detail

      • getDisplayName

        public java.lang.String getDisplayName()
        Specified by:
        getDisplayName in class org.openrewrite.Recipe
      • getDescription

        public java.lang.String getDescription()
        Overrides:
        getDescription in class org.openrewrite.Recipe
      • getApplicableTest

        @Nullable
        protected @Nullable org.openrewrite.TreeVisitor<?,​org.openrewrite.ExecutionContext> getApplicableTest()
        Overrides:
        getApplicableTest in class org.openrewrite.Recipe
      • getVisitor

        protected org.openrewrite.TreeVisitor<?,​org.openrewrite.ExecutionContext> getVisitor()
        Overrides:
        getVisitor in class org.openrewrite.Recipe