Skip to content

Conversation

@amishra-u
Copy link
Contributor

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

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

…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
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
amishra-u and others added 2 commits December 21, 2025 15:51
github suggestions

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timtebeek timtebeek added recipe Recipe request junit labels Dec 22, 2025
@timtebeek timtebeek self-requested a review December 22, 2025 09:18
Copy link
Member

@timtebeek timtebeek left a 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.

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Dec 22, 2025
@timtebeek timtebeek merged commit 9cd08b2 into openrewrite:main Dec 22, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Dec 22, 2025
mergify bot added a commit to robfrank/linklift that referenced this pull request Jan 9, 2026
…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)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-testing-frameworks&package-manager=maven&previous-version=3.24.0&new-version=3.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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

junit recipe Recipe request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants