Class ParameterizedRunnerToParameterized
- java.lang.Object
-
- org.openrewrite.Recipe
-
- org.openrewrite.java.testing.junit5.ParameterizedRunnerToParameterized
-
public class ParameterizedRunnerToParameterized extends org.openrewrite.RecipeRecipe 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;
-
-
Constructor Summary
Constructors Constructor Description ParameterizedRunnerToParameterized()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected @Nullable org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext>getApplicableTest()java.lang.StringgetDescription()java.lang.StringgetDisplayName()protected org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext>getVisitor()
-
-
-
Method Detail
-
getDisplayName
public java.lang.String getDisplayName()
- Specified by:
getDisplayNamein classorg.openrewrite.Recipe
-
getDescription
public java.lang.String getDescription()
- Overrides:
getDescriptionin classorg.openrewrite.Recipe
-
getApplicableTest
@Nullable protected @Nullable org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getApplicableTest()
- Overrides:
getApplicableTestin classorg.openrewrite.Recipe
-
getVisitor
protected org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()
- Overrides:
getVisitorin classorg.openrewrite.Recipe
-
-