From a69fda955489cdc05970be3282b83031f90d8c5e Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sun, 25 Oct 2026 13:58:21 +0100 Subject: [PATCH] Tighten preconditions that were too broad or too narrow --- .../AdoptAssertJDurationAssertions.java | 18 +- .../KotlinTestMethodsShouldReturnUnit.java | 2 +- .../cleanup/TestMethodsShouldBeVoid.java | 11 +- .../testing/hamcrest/RemoveIsMatcher.java | 2 +- .../resources/META-INF/rewrite/easymock.yml | 15 +- .../resources/META-INF/rewrite/recipes.csv | 19 +- .../META-INF/rewrite/testcontainers.yml | 2 + src/main/resources/META-INF/rewrite/truth.yml | 22 ++- .../resources/META-INF/rewrite/wiremock4.yml | 179 ++++++++++-------- ...KotlinTestMethodsShouldReturnUnitTest.java | 33 ++++ 10 files changed, 195 insertions(+), 108 deletions(-) diff --git a/src/main/java/org/openrewrite/java/testing/assertj/AdoptAssertJDurationAssertions.java b/src/main/java/org/openrewrite/java/testing/assertj/AdoptAssertJDurationAssertions.java index 9431ce4a0..0edc0a201 100644 --- a/src/main/java/org/openrewrite/java/testing/assertj/AdoptAssertJDurationAssertions.java +++ b/src/main/java/org/openrewrite/java/testing/assertj/AdoptAssertJDurationAssertions.java @@ -32,6 +32,7 @@ import java.util.*; import static java.util.Objects.requireNonNull; +import static org.openrewrite.Preconditions.and; import static org.openrewrite.Preconditions.or; public class AdoptAssertJDurationAssertions extends Recipe { @@ -74,13 +75,16 @@ public class AdoptAssertJDurationAssertions extends Recipe { @Override public TreeVisitor getVisitor() { return Preconditions.check( - or( - new UsesMethod<>(INTEGER_ASSERT_IS_EQUAL_TO, true), - new UsesMethod<>(INTEGER_ASSERT_IS_GREATER_THAN, true), - new UsesMethod<>(INTEGER_ASSERT_IS_LESS_THAN, true), - new UsesMethod<>(LONG_ASSERT_IS_EQUAL_TO, true), - new UsesMethod<>(LONG_ASSERT_IS_GREATER_THAN, true), - new UsesMethod<>(LONG_ASSERT_IS_LESS_THAN, true) + and( + new UsesMethod<>("java.time.Duration *(..)"), + or( + new UsesMethod<>(INTEGER_ASSERT_IS_EQUAL_TO, true), + new UsesMethod<>(INTEGER_ASSERT_IS_GREATER_THAN, true), + new UsesMethod<>(INTEGER_ASSERT_IS_LESS_THAN, true), + new UsesMethod<>(LONG_ASSERT_IS_EQUAL_TO, true), + new UsesMethod<>(LONG_ASSERT_IS_GREATER_THAN, true), + new UsesMethod<>(LONG_ASSERT_IS_LESS_THAN, true) + ) ), new JavaIsoVisitor() { @Override public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { diff --git a/src/main/java/org/openrewrite/java/testing/cleanup/KotlinTestMethodsShouldReturnUnit.java b/src/main/java/org/openrewrite/java/testing/cleanup/KotlinTestMethodsShouldReturnUnit.java index 11081bf9b..1f7066a73 100644 --- a/src/main/java/org/openrewrite/java/testing/cleanup/KotlinTestMethodsShouldReturnUnit.java +++ b/src/main/java/org/openrewrite/java/testing/cleanup/KotlinTestMethodsShouldReturnUnit.java @@ -58,7 +58,7 @@ public class KotlinTestMethodsShouldReturnUnit extends Recipe { @Override public TreeVisitor getVisitor() { - return Preconditions.check(new UsesType<>(TEST_ANNOTATION_TYPE_PATTERN, true), new KotlinIsoVisitor() { + return Preconditions.check(Preconditions.or(new UsesType<>(TEST_ANNOTATION_TYPE_PATTERN, true), new UsesType<>("org.testng.annotations.Test", true)), new KotlinIsoVisitor() { @Override public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext ctx) { J.MethodDeclaration m = super.visitMethodDeclaration(method, ctx); diff --git a/src/main/java/org/openrewrite/java/testing/cleanup/TestMethodsShouldBeVoid.java b/src/main/java/org/openrewrite/java/testing/cleanup/TestMethodsShouldBeVoid.java index aef6dbfae..6491e61f2 100644 --- a/src/main/java/org/openrewrite/java/testing/cleanup/TestMethodsShouldBeVoid.java +++ b/src/main/java/org/openrewrite/java/testing/cleanup/TestMethodsShouldBeVoid.java @@ -39,8 +39,6 @@ public class TestMethodsShouldBeVoid extends Recipe { - private static final String TEST_ANNOTATION_TYPE_PATTERN = "org..*Test"; - @Getter final String displayName = "Test methods should have void return type"; @@ -51,7 +49,14 @@ public class TestMethodsShouldBeVoid extends Recipe { @Override public TreeVisitor getVisitor() { - return Preconditions.check(Preconditions.and(new JavaFileChecker<>(), new UsesType<>(TEST_ANNOTATION_TYPE_PATTERN, true)), new JavaIsoVisitor() { + return Preconditions.check(Preconditions.and( + new JavaFileChecker<>(), + Preconditions.or( + new UsesType<>("org.junit.jupiter.api.Test", false), + new UsesType<>("org.junit.jupiter.api.RepeatedTest", false), + new UsesType<>("org.junit.jupiter.params.ParameterizedTest", false), + new UsesType<>("org.junit.jupiter.api.TestTemplate", false)) + ), new JavaIsoVisitor() { @Override public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext ctx) { J.MethodDeclaration m = super.visitMethodDeclaration(method, ctx); diff --git a/src/main/java/org/openrewrite/java/testing/hamcrest/RemoveIsMatcher.java b/src/main/java/org/openrewrite/java/testing/hamcrest/RemoveIsMatcher.java index 25b882ad3..b66dd7698 100644 --- a/src/main/java/org/openrewrite/java/testing/hamcrest/RemoveIsMatcher.java +++ b/src/main/java/org/openrewrite/java/testing/hamcrest/RemoveIsMatcher.java @@ -37,7 +37,7 @@ public class RemoveIsMatcher extends Recipe { @Override public TreeVisitor getVisitor() { - return Preconditions.check(new UsesMethod<>(ASSERT_THAT_MATCHER), new JavaVisitor() { + return Preconditions.check(Preconditions.and(new UsesMethod<>(IS_MATCHER), new UsesMethod<>(ASSERT_THAT_MATCHER)), new JavaVisitor() { @Override public J visitMethodInvocation(J.MethodInvocation mi, ExecutionContext ctx) { if (ASSERT_THAT_MATCHER.matches(mi)) { diff --git a/src/main/resources/META-INF/rewrite/easymock.yml b/src/main/resources/META-INF/rewrite/easymock.yml index 0768965d2..e01ddc865 100644 --- a/src/main/resources/META-INF/rewrite/easymock.yml +++ b/src/main/resources/META-INF/rewrite/easymock.yml @@ -33,6 +33,20 @@ recipeList: - org.openrewrite.java.dependencies.RemoveDependency: groupId: org.easymock artifactId: easymock + - org.openrewrite.java.testing.easymock.EasyMockCodeToMockito + - org.openrewrite.java.testing.mockito.MockitoBestPractices +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.testing.easymock.EasyMockCodeToMockito +displayName: Migrate EasyMock code to Mockito +description: Change EasyMock types, mock creation, expectations and argument matchers to their Mockito equivalents, and remove replay and verify calls. +preconditions: + - org.openrewrite.java.search.HasType: + fullyQualifiedTypeName: org.easymock..* +tags: + - testing + - easymock +recipeList: - org.openrewrite.java.testing.easymock.EasyMockVerifyToMockitoVerify - org.openrewrite.java.RemoveMethodInvocations: methodPattern: org.easymock.IExpectationSetters times(..) @@ -156,4 +170,3 @@ recipeList: - org.openrewrite.java.ChangeType: oldFullyQualifiedTypeName: org.easymock.TestSubject newFullyQualifiedTypeName: org.mockito.InjectMocks - - org.openrewrite.java.testing.mockito.MockitoBestPractices diff --git a/src/main/resources/META-INF/rewrite/recipes.csv b/src/main/resources/META-INF/rewrite/recipes.csv index b4c4badb0..c5e5b8034 100644 --- a/src/main/resources/META-INF/rewrite/recipes.csv +++ b/src/main/resources/META-INF/rewrite/recipes.csv @@ -47,7 +47,7 @@ maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.tes maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.AssertJShortRulesRecipes$AbstractShortAssertIsOneRecipe,Replace `isEqualTo(1)` with `isOne()`,Replace `isEqualTo(1)` with `isOne()`.,1,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.AssertJShortRulesRecipes$AbstractShortAssertIsZeroRecipe,Replace `isEqualTo(0)` with `isZero()`,Replace `isEqualTo(0)` with `isZero()`.,1,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.AssertJShortRulesRecipes,Adopt AssertJ Short Assertions,Adopt AssertJ Short Assertions. Favor semantically explicit methods (e.g. `myShort.isZero()` over `myShort.isEqualTo(0)`).,6,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.Assertj,AssertJ best practices,Migrates JUnit asserts to AssertJ and applies best practices to assertions.,1048,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]},{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.Assertj,AssertJ best practices,Migrates JUnit asserts to AssertJ and applies best practices to assertions.,1051,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]},{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.CollapseConsecutiveAssertThatStatements,Collapse consecutive `assertThat` statements,Collapse consecutive `assertThat` statements into single `assertThat` chained statement. This recipe ignores `assertThat` statements that have method invocation as parameter.,1,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.DecomposeConjunctionAssertion,Decompose `assertThat` on conjunctions into separate assertions,"Split `assertThat(a && b).isTrue()` into separate `assertThat(a).isTrue()` and `assertThat(b).isTrue()` statements, so each condition is asserted (and reported) on its own. This lets the dedicated assertion recipes simplify each conjunct, and `CollapseConsecutiveAssertThatStatements` fuse them back into a single chain when the actual is a plain expression. Only the direct `assertThat(...).isTrue()` form is decomposed; `isFalse()` is left alone, as negating a conjunction is not equivalent to negating each conjunct.",1,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.FestToAssertj,Migrate Fest 2.x to AssertJ,"AssertJ provides a rich set of assertions, truly helpful error messages, improves test code readability. Converts Fest 2.x imports to AssertJ imports.",10,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, @@ -63,7 +63,7 @@ maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.tes maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.JUnitAssertThrowsToAssertExceptionType,JUnit AssertThrows to AssertJ exceptionType,Convert `JUnit#AssertThrows` to `AssertJ#assertThatExceptionOfType` to allow for chained assertions on the thrown exception.,1,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.JUnitAssertTrueToAssertThat,JUnit `assertTrue` to AssertJ,Convert JUnit-style `assertTrue()` to AssertJ's `assertThat().isTrue()`.,1,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.JUnitFailToAssertJFail,JUnit fail to AssertJ,Convert JUnit-style `fail()` to AssertJ's `fail()`.,1,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.JUnitToAssertj,Migrate JUnit asserts to AssertJ,"AssertJ provides a rich set of assertions, truly helpful error messages, improves test code readability. Converts assertions from `org.junit.jupiter.api.Assertions` to `org.assertj.core.api.Assertions`. Will convert JUnit 4 to JUnit Jupiter if necessary to match and modify assertions.",480,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]},{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.JUnitToAssertj,Migrate JUnit asserts to AssertJ,"AssertJ provides a rich set of assertions, truly helpful error messages, improves test code readability. Converts assertions from `org.junit.jupiter.api.Assertions` to `org.assertj.core.api.Assertions`. Will convert JUnit 4 to JUnit Jupiter if necessary to match and modify assertions.",482,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]},{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.JUnitTryFailToAssertThatThrownBy,Convert try-catch-fail blocks to AssertJ's assertThatThrownBy,"Replace try-catch blocks where the try block ends with a `fail()` statement and the catch block optionally contains assertions, with AssertJ's `assertThatThrownBy()`.",1,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.MigrateAssertionsForClassAndInterfaceTypes,Migrate `AssertionsForClassTypes` and `AssertionsForInterfaceTypes` to `Assertions`,"AssertJ deprecated `AssertionsForClassTypes` and `AssertionsForInterfaceTypes` in favor of the unified `Assertions` entry point. This recipe retargets their static methods to `Assertions`, using `assertThatObject` where a plain `assertThat` would otherwise re-bind to a more specific overload and stop compiling (see https://github.com/openrewrite/rewrite-testing-frameworks/issues/664).",4,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.assertj.MigrateAssertionsForClassTypes,Use `Assertions.assertThatObject` for ambiguous `AssertionsForClassTypes.assertThat` calls,"The deprecated `AssertionsForClassTypes.assertThat(T)` always returns an `ObjectAssert`, while the unified `Assertions.assertThat` additionally offers more specific overloads (e.g. for `Iterable`, `Map`, `Predicate`). For arguments matching those overloads, rename `assertThat` to `assertThatObject` so that migrating to `Assertions` keeps returning an `ObjectAssert` and the code keeps compiling.",1,AssertJ,Testing,Java,,,Basic building blocks for transforming Java code.,, @@ -110,7 +110,8 @@ maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.tes maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.datafaker.JavaFakerToDataFaker,Migrate from Java Faker to Datafaker,Change imports and dependencies related to Java Faker to Datafaker replacements.,6,DataFaker,Testing,Java,Recipes for migrating from JavaFaker to [DataFaker](https://www.datafaker.net/).,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.dbrider.ExecutionListenerToDbRiderAnnotation,Migrate the `DBRiderTestExecutionListener` to the `@DBRider` annotation,Migrate the `DBRiderTestExecutionListener` to the `@DBRider` annotation. This recipe is useful when migrating from JUnit 4 `dbrider-spring` to JUnit 5 `dbrider-junit5`.,1,DBRider,Testing,Java,Recipes for [DBRider](https://database-rider.github.io/database-rider/) database testing framework.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.dbrider.MigrateDbRiderSpringToDbRiderJUnit5,Migrate rider-spring (JUnit4) to rider-junit5 (JUnit5),This recipe will migrate the necessary dependencies and annotations from DbRider with JUnit4 to JUnit5 in a Spring application.,3,DBRider,Testing,Java,Recipes for [DBRider](https://database-rider.github.io/database-rider/) database testing framework.,,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.easymock.EasyMockToMockito,Migrate from EasyMock to Mockito,This recipe will apply changes commonly needed when migrating from EasyMock to Mockito.,154,EasyMock,Testing,Java,Recipes for migrating from [EasyMock](https://easymock.org/) to Mockito.,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]}]" +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.easymock.EasyMockCodeToMockito,Migrate EasyMock code to Mockito,"Change EasyMock types, mock creation, expectations and argument matchers to their Mockito equivalents, and remove replay and verify calls.",44,EasyMock,Testing,Java,Recipes for migrating from [EasyMock](https://easymock.org/) to Mockito.,,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.easymock.EasyMockToMockito,Migrate from EasyMock to Mockito,This recipe will apply changes commonly needed when migrating from EasyMock to Mockito.,155,EasyMock,Testing,Java,Recipes for migrating from [EasyMock](https://easymock.org/) to Mockito.,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]}]" maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.easymock.EasyMockVerifyToMockitoVerify,Replace EasyMock `verify` calls with Mockito `verify` calls,Replace `EasyMock.verify(dependency)` with individual `Mockito.verify(dependency).method()` calls based on expected methods.,1,EasyMock,Testing,Java,Recipes for migrating from [EasyMock](https://easymock.org/) to Mockito.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.easymock.RemoveExtendsEasyMockSupport,Migrate Test classes that extend `org.easymock.EasyMockSupport` to use Mockito,Modify test classes by removing extends EasyMockSupport and replacing EasyMock methods with Mockito equivalents.,1,EasyMock,Testing,Java,Recipes for migrating from [EasyMock](https://easymock.org/) to Mockito.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.hamcrest.AddHamcrestIfUsed,Add `org.hamcrest:hamcrest` if it is used,JUnit Jupiter does not include Hamcrest as a transitive dependency. Add a direct dependency for existing Hamcrest usage or ExpectedException assertions that generate Hamcrest usage during migration.,1,Hamcrest,Testing,Java,Recipes for migrating from [Hamcrest](http://hamcrest.org/) matchers to AssertJ.,,Basic building blocks for transforming Java code.,, @@ -161,8 +162,8 @@ maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.tes maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.HandleExternalResourceRules,Handle the usage of ExternalResourceRule fields using @ExtendWith(ExternalResourceSupport.class),Handles the usage of the ExternalResourceRule fields by adding the @ExtendWith(ExternalResourceSupport.class) annotation to the test class.,1,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.IgnoreToDisabled,Use JUnit Jupiter `@Disabled`,Migrates JUnit 4.x `@Ignore` to JUnit Jupiter `@Disabled`.,2,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.ImplausibleTimeoutToMinutes,Make implausibly long `@Timeout` values explicit in minutes,"JUnit Jupiter's `@Timeout` defaults to `TimeUnit.SECONDS`, so a value such as `@Timeout(10000)` is interpreted as almost three hours, which is most likely a mistake where milliseconds were intended. This recipe rewrites such implausibly large second-based timeouts to the equivalent number of minutes, for instance `@Timeout(value = 167, unit = TimeUnit.MINUTES)`, preserving the original (likely erroneous) semantics while making the mistake far more visible for review.",1,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,"[{""name"":""thresholdSeconds"",""type"":""Integer"",""displayName"":""Threshold in seconds"",""description"":""Timeouts of at least this many seconds (when the time unit is the default `SECONDS`) are considered implausibly long and are rewritten to the equivalent number of minutes. Defaults to `1000` seconds, about 17 minutes."",""example"":""1000""}]", -maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.JUnit4to5Migration,JUnit Jupiter migration from JUnit 4.x,Migrates JUnit 4.x tests to JUnit Jupiter.,334,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]},{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" -maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.JUnit5BestPractices,JUnit 5 best practices,Applies best practices to tests.,407,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]},{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.JUnit4to5Migration,JUnit Jupiter migration from JUnit 4.x,Migrates JUnit 4.x tests to JUnit Jupiter.,336,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]},{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.JUnit5BestPractices,JUnit 5 best practices,Applies best practices to tests.,409,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]},{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.JUnitParamsRunnerToParameterized,Pragmatists `@RunWith(JUnitParamsRunner.class)` to JUnit Jupiter `@Parameterized` tests,Convert Pragmatists Parameterized test to the JUnit Jupiter ParameterizedTest equivalent.,1,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.JUnitSoftAssertionsToSoftAssertionsExtension,AssertJ `@Rule` soft assertions to `SoftAssertionsExtension`,"Replaces `@Rule` fields of type `JUnitSoftAssertions` or `JUnitBDDSoftAssertions` with `@InjectSoftAssertions` fields, and registers `@ExtendWith(SoftAssertionsExtension.class)` on the test class. JUnit Jupiter does not run JUnit 4 rules, so soft assertions collected through such a rule would otherwise never be reported, silently passing tests that ought to fail.",1,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.LifecycleNonPrivate,Make lifecycle methods non private,"Make JUnit 5's `@AfterAll`, `@AfterEach`, `@BeforeAll` and `@BeforeEach` non private.",1,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, @@ -196,7 +197,7 @@ maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.tes maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.UpgradeToJUnit514,Upgrade to JUnit 5.14,Upgrades JUnit 5 to 5.14.x and migrates all deprecated APIs.,24,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.UseAssertSame,Use JUnit5's `assertSame` or `assertNotSame` instead of `assertTrue(... == ...)`,Prefers the usage of `assertSame` or `assertNotSame` methods instead of using of vanilla `assertTrue` or `assertFalse` with a boolean comparison. Only applies when both operands are reference types — primitive operands are handled by `AssertTrueComparisonToAssertEquals`.,1,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.UseHamcrestAssertThat,Use `MatcherAssert#assertThat(..)`,JUnit 4's `Assert#assertThat(..)` This method was deprecated in JUnit 4 and removed in JUnit Jupiter.,3,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.UseMockitoExtension,Use Mockito JUnit Jupiter extension,Migrate uses of `@RunWith(MockitoJUnitRunner.class)` (and similar annotations) to `@ExtendWith(MockitoExtension.class)`.,100,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]}]" +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.UseMockitoExtension,Use Mockito JUnit Jupiter extension,Migrate uses of `@RunWith(MockitoJUnitRunner.class)` (and similar annotations) to `@ExtendWith(MockitoExtension.class)`.,101,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled"",""displayName"":""PowerMock tests disabled for manual migration"",""instanceName"":""PowerMock tests disabled for manual migration"",""description"":""Tests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it."",""columns"":[{""name"":""sourcePath"",""type"":""String"",""displayName"":""Source path"",""description"":""The path of the test source file.""},{""name"":""testClass"",""type"":""String"",""displayName"":""Test class"",""description"":""The test class the disabled test belongs to.""},{""name"":""disabledElement"",""type"":""String"",""displayName"":""Disabled element"",""description"":""The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled.""},{""name"":""scope"",""type"":""String"",""displayName"":""Scope"",""description"":""`METHOD` when a single test was disabled, `CLASS` when the whole test class was.""},{""name"":""reason"",""type"":""String"",""displayName"":""Reason"",""description"":""The PowerMock usage that cannot be migrated.""}]}]" maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.UseTestMethodOrder,Migrate from JUnit 4 `@FixedMethodOrder` to JUnit 5 `@TestMethodOrder`,JUnit optionally allows test method execution order to be specified. This replaces JUnit 4 test execution ordering annotations with JUnit 5 replacements.,1,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.UseWiremockExtension,Use wiremock extension,"As of 2.31.0, wiremock [supports JUnit 5](https://wiremock.org/docs/junit-jupiter/) via an extension.",1,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.junit5.UseXMLUnitLegacy,Use XMLUnit Legacy for JUnit 5,Migrates XMLUnit 1.x to XMLUnit legacy 2.x.,2,JUnit Jupiter,Testing,Java,Best practices for JUnit Jupiter tests.,,Basic building blocks for transforming Java code.,, @@ -293,9 +294,10 @@ maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.tes maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.testng.TestNgAssertionToAssertJ,TestNG `Assertion` to AssertJ,"Convert TestNG-style hard assertions on `org.testng.asserts.Assertion` instances to static AssertJ `assertThat(...)`, removing the now-unused local `Assertion` instance.",1,TestNG,Testing,Java,Recipes for migrating from [TestNG](https://testng.org/) to JUnit.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.testng.TestNgSoftAssertToAssertJ,TestNG `SoftAssert` to AssertJ `SoftAssertions`,Convert TestNG-style soft assertions (`org.testng.asserts.SoftAssert`) to AssertJ soft assertions (`org.assertj.core.api.SoftAssertions`).,1,TestNG,Testing,Java,Recipes for migrating from [TestNG](https://testng.org/) to JUnit.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.testng.TestNgToAssertj,Migrate TestNG assertions to AssertJ,Convert assertions from `org.testng.Assert` to `org.assertj.core.api.Assertions`.,56,TestNG,Testing,Java,Recipes for migrating from [TestNG](https://testng.org/) to JUnit.,,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.truth.MigrateTruthToAssertJ,Migrate Google Truth to AssertJ,Migrate Google Truth assertions to AssertJ assertions.,56,Google Truth,Testing,Java,,,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.truth.MigrateTruthToAssertJ,Migrate Google Truth to AssertJ,Migrate Google Truth assertions to AssertJ assertions.,57,Google Truth,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.truth.TruthAssertToAssertThat,Convert Truth `assert_()` to AssertJ,Converts Google Truth's `assert_()` method to AssertJ's standard assertion pattern.,1,Google Truth,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.truth.TruthAssertWithMessageToAssertJ,Convert Truth `assertWithMessage` to AssertJ,Converts Google Truth's `assertWithMessage().that()` pattern to AssertJ's `assertThat().as()` pattern.,1,Google Truth,Testing,Java,,,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.truth.TruthCodeToAssertJ,Migrate Google Truth code to AssertJ,"Convert Google Truth assertions, subject types and their methods to AssertJ equivalents.",54,Google Truth,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.truth.TruthCustomSubjectsToAssertJ,Migrate Truth custom subjects to AssertJ,Marks Google Truth's `assertAbout()` usage for manual review as AssertJ handles custom assertions differently.,1,Google Truth,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.truth.TruthThrowableAssertions,Convert Truth Throwable assertions to AssertJ,Converts Google Truth's Throwable assertion chains like `hasMessageThat().contains()` to AssertJ equivalents.,1,Google Truth,Testing,Java,,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.wiremock.MigrateContentTypeHeaderCharset,Preserve the UTF-8 default of `ContentTypeHeader.charset()`,"WireMock 3's `ContentTypeHeader.charset()` fell back to `UTF_8` when the header was missing or carried no charset, while 4.x returns an `Optional` that is empty in those cases. Append `orElse(StandardCharsets.UTF_8)` so the value stays what it was; reaching for `get()` or `orElse(null)` instead, which is the easy way to make the compiler happy, would turn a missing charset into an exception or a null.",1,WireMock,Testing,Java,Recipes for [WireMock](https://wiremock.org/) HTTP service mocking.,,Basic building blocks for transforming Java code.,, @@ -308,4 +310,5 @@ maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.tes maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.wiremock.ReplaceRemovedConstructors,Replace WireMock constructors removed in 4.x,"WireMock 4 made its primary domain classes immutable, leaving only the canonical all arguments constructor on each and moving everything else behind a builder. Replace the removed convenience constructors of `StubMapping`, `ResponseDefinition`, `RequestPattern` and `WireMock` with the equivalent builder call, and `RequestPattern.everything()` with `RequestPattern.ANYTHING`.",1,WireMock,Testing,Java,Recipes for [WireMock](https://wiremock.org/) HTTP service mocking.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.wiremock.ReplaceSettersWithTransform,Replace WireMock setter calls with `transform()`,"WireMock 4 made `StubMapping` and `ResponseDefinition` immutable, removing their setters in favour of a builder reached through `transform(Consumer)`. Rewrite in place mutation such as `stubMapping.setRequest(pattern);` to `stubMapping = stubMapping.transform(builder -> builder.setRequest(pattern));`, collapsing consecutive setter calls on the same receiver into a single `transform` call.",1,WireMock,Testing,Java,Recipes for [WireMock](https://wiremock.org/) HTTP service mocking.,,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.wiremock.UpgradeWiremockDependencyVersion,Upgrade WireMock to 3.x,Migrate WireMock dependencies from the old `com.github.tomakehurst` coordinates to the new `org.wiremock` coordinates. WireMock 3.x changed its Maven coordinates and requires Java 11 or higher. Old 2.x versions contain CVE-2023-44487.,5,WireMock,Testing,Java,Recipes for [WireMock](https://wiremock.org/) HTTP service mocking.,,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.wiremock.Wiremock3to4Migration,Upgrade WireMock to 4.x,"Upgrade WireMock to 4.x, which requires Java 17, ships Jetty 12.1 by default, splits JUnit support out into separate modules and makes the primary domain classes immutable. Note that `RequestMethod.GET_OR_HEAD` is a multi method matcher in 4.x rather than a method named `GET_OR_HEAD`, so code reading a name off that particular constant needs a look.",66,WireMock,Testing,Java,Recipes for [WireMock](https://wiremock.org/) HTTP service mocking.,,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.wiremock.Wiremock3to4Migration,Upgrade WireMock to 4.x,"Upgrade WireMock to 4.x, which requires Java 17, ships Jetty 12.1 by default, splits JUnit support out into separate modules and makes the primary domain classes immutable. Note that `RequestMethod.GET_OR_HEAD` is a multi method matcher in 4.x rather than a method named `GET_OR_HEAD`, so code reading a name off that particular constant needs a look.",67,WireMock,Testing,Java,Recipes for [WireMock](https://wiremock.org/) HTTP service mocking.,,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-testing-frameworks,org.openrewrite.java.testing.wiremock.Wiremock4RelocatedTypes,Move WireMock types to their 4.x packages,"Change WireMock types that moved packages in WireMock 4.x, such as the Jetty, servlet and Apache HTTP client classes.",36,WireMock,Testing,Java,Recipes for [WireMock](https://wiremock.org/) HTTP service mocking.,,Basic building blocks for transforming Java code.,, diff --git a/src/main/resources/META-INF/rewrite/testcontainers.yml b/src/main/resources/META-INF/rewrite/testcontainers.yml index 6f1ef1275..d90988ec0 100644 --- a/src/main/resources/META-INF/rewrite/testcontainers.yml +++ b/src/main/resources/META-INF/rewrite/testcontainers.yml @@ -625,6 +625,8 @@ displayName: Testcontainers 2 container classes description: Change Testcontainers container classes to their new package locations in Testcontainers 2.x. preconditions: - org.openrewrite.Singleton + - org.openrewrite.java.search.HasType: + fullyQualifiedTypeName: org.testcontainers..* recipeList: - org.openrewrite.java.ChangeType: oldFullyQualifiedTypeName: org.testcontainers.containers.BigQueryEmulatorContainer diff --git a/src/main/resources/META-INF/rewrite/truth.yml b/src/main/resources/META-INF/rewrite/truth.yml index 220112f03..7d873691c 100644 --- a/src/main/resources/META-INF/rewrite/truth.yml +++ b/src/main/resources/META-INF/rewrite/truth.yml @@ -34,6 +34,24 @@ recipeList: onlyIfUsing: com.google.common.truth.* acceptTransitive: true + - org.openrewrite.java.testing.truth.TruthCodeToAssertJ + + - org.openrewrite.java.dependencies.RemoveDependency: + groupId: com.google.truth + artifactId: truth +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.testing.truth.TruthCodeToAssertJ +displayName: Migrate Google Truth code to AssertJ +description: Convert Google Truth assertions, subject types and their methods to AssertJ equivalents. +preconditions: + - org.openrewrite.java.search.HasType: + fullyQualifiedTypeName: com.google.common.truth..* +tags: + - testing + - truth + - assertj +recipeList: # Handle Truth's assert_() static method - org.openrewrite.java.testing.truth.TruthAssertToAssertThat # Handle assertWithMessage conversions @@ -220,7 +238,3 @@ recipeList: - org.openrewrite.java.ChangeType: oldFullyQualifiedTypeName: com.google.common.truth.Truth newFullyQualifiedTypeName: org.assertj.core.api.Assertions - - - org.openrewrite.java.dependencies.RemoveDependency: - groupId: com.google.truth - artifactId: truth diff --git a/src/main/resources/META-INF/rewrite/wiremock4.yml b/src/main/resources/META-INF/rewrite/wiremock4.yml index 83ca9ba01..c8a608b1f 100644 --- a/src/main/resources/META-INF/rewrite/wiremock4.yml +++ b/src/main/resources/META-INF/rewrite/wiremock4.yml @@ -75,6 +75,102 @@ recipeList: artifactId: jetty-xml version: 12.1.x onlyIfUsing: org.eclipse.jetty.xml.* + - org.openrewrite.java.testing.wiremock.Wiremock4RelocatedTypes + - org.openrewrite.java.testing.wiremock.ReplaceRemovedConstructors + - org.openrewrite.java.testing.wiremock.ReplaceSettersWithTransform + - org.openrewrite.java.testing.wiremock.MigrateStubMappingUuidToId + - org.openrewrite.java.testing.wiremock.MigrateContentTypeHeaderCharset + - org.openrewrite.java.testing.wiremock.MigrateRequestMethodIsOneOf + - org.openrewrite.java.ChangeMethodName: + methodPattern: com.github.tomakehurst.wiremock.stubbing.StubMapping getUuid() + newMethodName: getId + # `value()` widened its return type to `Object` in 4.x; `getName()` still answers a `String` + - org.openrewrite.java.ChangeMethodName: + methodPattern: com.github.tomakehurst.wiremock.http.RequestMethod value() + newMethodName: getName +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.testing.wiremock.RemoveDuplicateContentTypeHeaders +displayName: Keep a single `Content-Type` response header while still on WireMock 3 +description: >- + Collapse duplicate `Content-Type` response headers in both stub files and the Java DSL, but only where the + module still depends on WireMock 3.x. Jetty 11 already served a single value there, so dropping the rest + changes nothing; against 4.x the extra values really do reach the client, and removing them would. +tags: + - testing + - wiremock +preconditions: + - org.openrewrite.java.dependencies.search.ModuleHasDependency: + groupIdPattern: org.wiremock + artifactIdPattern: wiremock* + version: 3.x +recipeList: + - org.openrewrite.java.testing.wiremock.RemoveDuplicateContentTypeHeader + - org.openrewrite.java.testing.wiremock.RemoveDuplicateContentTypeStubHeader +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.testing.wiremock.MigrateJettyEE10ToEE11 +displayName: Move Jetty EE10 usages to EE11 alongside `wiremock-jetty12` +description: >- + WireMock 3's `wiremock-jetty12` module ran on Jetty's EE10 servlet environment, whereas WireMock 4.x runs on EE11, + so EE10 types such as the `ServletContextHandler` handed to `NotFoundHandler` no longer line up. Move EE10 packages + and dependencies over to their EE11 counterparts, but only in modules depending on `wiremock-jetty12`, where EE10 + arrived through WireMock in the first place. +tags: + - testing + - wiremock + - jetty +preconditions: + - org.openrewrite.java.dependencies.search.ModuleHasDependency: + groupIdPattern: org.wiremock + artifactIdPattern: wiremock-jetty12 +recipeList: + - org.openrewrite.java.ChangePackage: + oldPackageName: org.eclipse.jetty.ee10 + newPackageName: org.eclipse.jetty.ee11 + recursive: true + - org.openrewrite.java.dependencies.ChangeDependency: + oldGroupId: org.eclipse.jetty.ee10 + oldArtifactId: jetty-ee10-servlet + newGroupId: org.eclipse.jetty.ee11 + newArtifactId: jetty-ee11-servlet + newVersion: 12.1.x + - org.openrewrite.java.dependencies.ChangeDependency: + oldGroupId: org.eclipse.jetty.ee10 + oldArtifactId: jetty-ee10-servlets + newGroupId: org.eclipse.jetty.ee11 + newArtifactId: jetty-ee11-servlets + newVersion: 12.1.x + - org.openrewrite.java.dependencies.ChangeDependency: + oldGroupId: org.eclipse.jetty.ee10 + oldArtifactId: jetty-ee10-webapp + newGroupId: org.eclipse.jetty.ee11 + newArtifactId: jetty-ee11-webapp + newVersion: 12.1.x + # WireMock 4.x only puts these on the runtime classpath. `onlyIfUsing` is matched against the sources as they + # were before `ChangePackage` ran, hence the EE10 packages. + - org.openrewrite.java.dependencies.AddDependency: + groupId: org.eclipse.jetty.ee11 + artifactId: jetty-ee11-webapp + version: 12.1.x + onlyIfUsing: org.eclipse.jetty.ee10.webapp.* + - org.openrewrite.java.dependencies.AddDependency: + groupId: org.eclipse.jetty.ee11 + artifactId: jetty-ee11-servlets + version: 12.1.x + onlyIfUsing: org.eclipse.jetty.ee10.servlets.* +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.testing.wiremock.Wiremock4RelocatedTypes +displayName: Move WireMock types to their 4.x packages +description: Change WireMock types that moved packages in WireMock 4.x, such as the Jetty, servlet and Apache HTTP client classes. +preconditions: + - org.openrewrite.java.search.HasType: + fullyQualifiedTypeName: com.github.tomakehurst.wiremock..* +tags: + - testing + - wiremock +recipeList: - org.openrewrite.java.ChangeType: oldFullyQualifiedTypeName: com.github.tomakehurst.wiremock.jetty11.CertificateGeneratingSslContextFactory newFullyQualifiedTypeName: com.github.tomakehurst.wiremock.jetty.ssl.CertificateGeneratingSslContextFactory @@ -215,86 +311,3 @@ recipeList: oldFullyQualifiedTypeName: com.github.tomakehurst.wiremock.http.MimeType newFullyQualifiedTypeName: com.github.tomakehurst.wiremock.common.entity.MimeType ignoreDefinition: true - - org.openrewrite.java.testing.wiremock.ReplaceRemovedConstructors - - org.openrewrite.java.testing.wiremock.ReplaceSettersWithTransform - - org.openrewrite.java.testing.wiremock.MigrateStubMappingUuidToId - - org.openrewrite.java.testing.wiremock.MigrateContentTypeHeaderCharset - - org.openrewrite.java.testing.wiremock.MigrateRequestMethodIsOneOf - - org.openrewrite.java.ChangeMethodName: - methodPattern: com.github.tomakehurst.wiremock.stubbing.StubMapping getUuid() - newMethodName: getId - # `value()` widened its return type to `Object` in 4.x; `getName()` still answers a `String` - - org.openrewrite.java.ChangeMethodName: - methodPattern: com.github.tomakehurst.wiremock.http.RequestMethod value() - newMethodName: getName ---- -type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.testing.wiremock.RemoveDuplicateContentTypeHeaders -displayName: Keep a single `Content-Type` response header while still on WireMock 3 -description: >- - Collapse duplicate `Content-Type` response headers in both stub files and the Java DSL, but only where the - module still depends on WireMock 3.x. Jetty 11 already served a single value there, so dropping the rest - changes nothing; against 4.x the extra values really do reach the client, and removing them would. -tags: - - testing - - wiremock -preconditions: - - org.openrewrite.java.dependencies.search.ModuleHasDependency: - groupIdPattern: org.wiremock - artifactIdPattern: wiremock* - version: 3.x -recipeList: - - org.openrewrite.java.testing.wiremock.RemoveDuplicateContentTypeHeader - - org.openrewrite.java.testing.wiremock.RemoveDuplicateContentTypeStubHeader ---- -type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.testing.wiremock.MigrateJettyEE10ToEE11 -displayName: Move Jetty EE10 usages to EE11 alongside `wiremock-jetty12` -description: >- - WireMock 3's `wiremock-jetty12` module ran on Jetty's EE10 servlet environment, whereas WireMock 4.x runs on EE11, - so EE10 types such as the `ServletContextHandler` handed to `NotFoundHandler` no longer line up. Move EE10 packages - and dependencies over to their EE11 counterparts, but only in modules depending on `wiremock-jetty12`, where EE10 - arrived through WireMock in the first place. -tags: - - testing - - wiremock - - jetty -preconditions: - - org.openrewrite.java.dependencies.search.ModuleHasDependency: - groupIdPattern: org.wiremock - artifactIdPattern: wiremock-jetty12 -recipeList: - - org.openrewrite.java.ChangePackage: - oldPackageName: org.eclipse.jetty.ee10 - newPackageName: org.eclipse.jetty.ee11 - recursive: true - - org.openrewrite.java.dependencies.ChangeDependency: - oldGroupId: org.eclipse.jetty.ee10 - oldArtifactId: jetty-ee10-servlet - newGroupId: org.eclipse.jetty.ee11 - newArtifactId: jetty-ee11-servlet - newVersion: 12.1.x - - org.openrewrite.java.dependencies.ChangeDependency: - oldGroupId: org.eclipse.jetty.ee10 - oldArtifactId: jetty-ee10-servlets - newGroupId: org.eclipse.jetty.ee11 - newArtifactId: jetty-ee11-servlets - newVersion: 12.1.x - - org.openrewrite.java.dependencies.ChangeDependency: - oldGroupId: org.eclipse.jetty.ee10 - oldArtifactId: jetty-ee10-webapp - newGroupId: org.eclipse.jetty.ee11 - newArtifactId: jetty-ee11-webapp - newVersion: 12.1.x - # WireMock 4.x only puts these on the runtime classpath. `onlyIfUsing` is matched against the sources as they - # were before `ChangePackage` ran, hence the EE10 packages. - - org.openrewrite.java.dependencies.AddDependency: - groupId: org.eclipse.jetty.ee11 - artifactId: jetty-ee11-webapp - version: 12.1.x - onlyIfUsing: org.eclipse.jetty.ee10.webapp.* - - org.openrewrite.java.dependencies.AddDependency: - groupId: org.eclipse.jetty.ee11 - artifactId: jetty-ee11-servlets - version: 12.1.x - onlyIfUsing: org.eclipse.jetty.ee10.servlets.* diff --git a/src/test/java/org/openrewrite/java/testing/cleanup/KotlinTestMethodsShouldReturnUnitTest.java b/src/test/java/org/openrewrite/java/testing/cleanup/KotlinTestMethodsShouldReturnUnitTest.java index ab3187500..8f9229493 100644 --- a/src/test/java/org/openrewrite/java/testing/cleanup/KotlinTestMethodsShouldReturnUnitTest.java +++ b/src/test/java/org/openrewrite/java/testing/cleanup/KotlinTestMethodsShouldReturnUnitTest.java @@ -107,6 +107,39 @@ fun myTest() { ); } + @Test + void removeReturnTypeFromTestNGTestMethod() { + //language=kotlin + rewriteRun( + spec -> spec.parser(KotlinParser.builder() + .classpathFromResources(new InMemoryExecutionContext(), + "testng-7")), + kotlin( + """ + import org.testng.annotations.Test + + class ATest { + @Test + fun myTest(): String { + println("test") + return "done" + } + } + """, + """ + import org.testng.annotations.Test + + class ATest { + @Test + fun myTest() { + println("test") + } + } + """ + ) + ); + } + @Test void removeReturnTypeAndPreserveReturnStatement() { //language=kotlin