-
Notifications
You must be signed in to change notification settings - Fork 99
Add recipe to migrate JUnit 4 ExternalResource rules using jupiter-migrationsupport #880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…gration support Implements HandleExternalResourceRules recipe to migrate JUnit 4 ExternalResource-based @rule and @ClassRule fields to JUnit 5 by adding @ExtendWith(ExternalResourceSupport.class) from junit-jupiter-migrationsupport. This provides a migration path for rules like TemporaryFolder and GrpcCleanupRule that extend ExternalResource but don't have direct JUnit 5 equivalents. Changes: - Add HandleExternalResourceRules recipe to detect ExternalResource-based rules - Add helper methods to Junit4Utils for checking @Rule/@ClassRule annotations - Add junit-jupiter-migrationsupport and grpc-testing dependencies for testing - Add comprehensive test coverage for field and method-based rules
src/main/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRules.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
github suggestions Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
src/test/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRulesTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/testing/junit5/HandleExternalResourceRules.java
Outdated
Show resolved
Hide resolved
timtebeek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @amishra-u ; good to see these rules flow back to the project to convert any left over cases beyond what was covered already.
I've applied a few small changes, mostly to add preconditions and reduce the usage of Annotated.Matcher when service(AnnotationService) ought to be enough.
…rom 3.24.0 to 3.25.0 [skip ci] Bumps [org.openrewrite.recipe:rewrite-testing-frameworks](https://github.com/openrewrite/rewrite-testing-frameworks) from 3.24.0 to 3.25.0. Release notes *Sourced from [org.openrewrite.recipe:rewrite-testing-frameworks's releases](https://github.com/openrewrite/rewrite-testing-frameworks/releases).* > 3.25.0 > ------ > > What's Changed > -------------- > > * add upgrade recipe for deprecated APIs introduced in junit 5.13 by [`@murdos`](https://github.com/murdos) in [openrewrite/rewrite-testing-frameworks#877](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/877) > * throwing ParseError.toException by [`@greg-at-moderne`](https://github.com/greg-at-moderne) in [openrewrite/rewrite-testing-frameworks#878](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/878) > * Add recipe to migrate JUnit 4 ExternalResource rules using jupiter-migrationsupport by [`@amishra-u`](https://github.com/amishra-u) in [openrewrite/rewrite-testing-frameworks#880](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/880) > * Drop `FindUnitTests` and associated data table by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#882](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/882) > * fix: HamcrestMatcherToAssertJ argumentType does not allow subclasses by [`@Gosho1024`](https://github.com/Gosho1024) in [openrewrite/rewrite-testing-frameworks#881](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/881) > * Convert TestContainers raw types as part of upgrade by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#883](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/883) > * Add or update recipe category descriptors by [`@jkschneider`](https://github.com/jkschneider) in [openrewrite/rewrite-testing-frameworks#884](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/884) > > New Contributors > ---------------- > > * [`@Gosho1024`](https://github.com/Gosho1024) made their first contribution in [openrewrite/rewrite-testing-frameworks#881](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/881) > > **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.24.0...v3.25.0> Commits * [`4b23569`](openrewrite/rewrite-testing-frameworks@4b23569) Update documentation examples * [`bc75310`](openrewrite/rewrite-testing-frameworks@bc75310) Update recipe documentation examples * [`657e7c3`](openrewrite/rewrite-testing-frameworks@657e7c3) Update recipes.csv to match * [`2509a44`](openrewrite/rewrite-testing-frameworks@2509a44) Fix `recipeCsvValidateContent` task * [`18a1ba0`](openrewrite/rewrite-testing-frameworks@18a1ba0) OpenRewrite recipe best practices * [`162c2e4`](openrewrite/rewrite-testing-frameworks@162c2e4) Generated recipes.csv. * [`98685c9`](openrewrite/rewrite-testing-frameworks@98685c9) Add or update recipe category descriptors ([#884](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/884)) * [`5d8da27`](openrewrite/rewrite-testing-frameworks@5d8da27) OpenRewrite recipe best practices * [`a23f69c`](openrewrite/rewrite-testing-frameworks@a23f69c) Convert TestContainers raw types as part of upgrade ([#883](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/883)) * [`a5c433b`](openrewrite/rewrite-testing-frameworks@a5c433b) fix: HamcrestMatcherToAssertJ argumentType does not allow subclasses ([#881](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/881)) * Additional commits viewable in [compare view](openrewrite/rewrite-testing-frameworks@v3.24.0...v3.25.0) [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Implements HandleExternalResourceRules recipe to migrate JUnit 4 ExternalResource-based @rule and @ClassRule fields to JUnit 5 by adding @ExtendWith(ExternalResourceSupport.class) from
junit-jupiter-migrationsupport. This provides a migration path for rules like TemporaryFolder and GrpcCleanupRule that extend ExternalResource but don't have direct JUnit 5 equivalents.
Changes:
Checklist