Conversation
Contributor
Author
|
I want to check over one other thing regarding making sure it can detect correctly when we don't actually have any JUnit or TestNG annotations in the current class. |
f2be2db to
e6c420f
Compare
…cutionListener Replace manual import loop in detectFramework() with FindImports search visitors for cleaner, more idiomatic framework detection.
Add a targetFramework @option that YAML wrapper recipes set based on ModuleHasDependency preconditions. Import-based detection still takes priority; the option is a fallback for files with no framework imports. Three YAML wrapper recipes gate on JUnit 5, JUnit 4, and TestNG dependencies respectively, replacing the single bare reference in Mockito1to3Migration.
Since JUnit 5 (org.junit.jupiter..*) is matched first, any remaining org.junit..* import is necessarily JUnit 4.
e6c420f to
d11ace5
Compare
FindImports and dependency-aware framework detection in ReplaceMockitoTestExecutionListener
timtebeek
approved these changes
Mar 9, 2026
Contributor
Author
|
Going to put in another small PR because when the |
mergify bot
added a commit
to robfrank/linklift
that referenced
this pull request
Mar 19, 2026
…rom 3.29.0 to 3.30.0 [skip ci] [//]: # (dependabot-start)⚠️ \*\*Dependabot is rebasing this PR\*\*⚠️ Rebasing might not happen immediately, so don't worry if this takes some time. Note: if you make any changes to this PR yourself, they will take precedence over the rebase. --- [//]: # (dependabot-end) Bumps [org.openrewrite.recipe:rewrite-testing-frameworks](https://github.com/openrewrite/rewrite-testing-frameworks) from 3.29.0 to 3.30.0. Release notes *Sourced from [org.openrewrite.recipe:rewrite-testing-frameworks's releases](https://github.com/openrewrite/rewrite-testing-frameworks/releases).* > 3.30.0 > ------ > > What's Changed > -------------- > > * Use `FindImports` and dependency-aware framework detection in `ReplaceMockitoTestExecutionListener` by [`@steve-aom-elliott`](https://github.com/steve-aom-elliott) in [openrewrite/rewrite-testing-frameworks#925](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/925) > * Align targetFramework switch value with [`@Option`](https://github.com/Option) valid values by [`@steve-aom-elliott`](https://github.com/steve-aom-elliott) in [openrewrite/rewrite-testing-frameworks#928](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/928) > * Add JSpecify to type table for `JUnitToAssertJRulesRecipes` by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#929](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/929) > * Fix CI failure from upstream AddDependency changes by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#931](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/931) > > **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.29.0...v3.30.0> Commits * [`5a24e73`](openrewrite/rewrite-testing-frameworks@5a24e73) Fix JUnit5MigrationTest.addMockitoJupiterDependencyIfExtendWithPresent ([#931](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/931)) * [`c789ee8`](openrewrite/rewrite-testing-frameworks@c789ee8) Lombok Best Practices * [`08296c5`](openrewrite/rewrite-testing-frameworks@08296c5) Rename `MockWebServer shutdown()` to `close` * [`40bd3da`](openrewrite/rewrite-testing-frameworks@40bd3da) OpenRewrite recipe best practices * [`467ab04`](openrewrite/rewrite-testing-frameworks@467ab04) Add JSpecify to type table for `JUnitToAssertJRulesRecipes` ([#929](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/929)) * [`92a9ca4`](openrewrite/rewrite-testing-frameworks@92a9ca4) Align targetFramework switch case with [`@Option`](https://github.com/Option) valid values ([#928](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/928)) * [`8654451`](openrewrite/rewrite-testing-frameworks@8654451) Use `FindImports` and dependency-aware framework detection in `ReplaceMockito... * [`6d5852e`](openrewrite/rewrite-testing-frameworks@6d5852e) OpenRewrite recipe best practices * See full diff in [compare view](openrewrite/rewrite-testing-frameworks@v3.29.0...v3.30.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 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
detectFramework()withFindImportssearch visitorstargetFrameworkoption for dependency-based framework detection when no imports are present...ForJUnit5,...ForJUnit4,...ForTestNG) gated byModuleHasDependencypreconditionsMockito1to3Migrationto use the wrapper recipes in priority orderWhen a file has
@TestExecutionListeners(MockitoTestExecutionListener.class)but no JUnit/TestNG imports (e.g., an abstract base class with only@Mockfields), the recipe previously defaulted to JUnit 5 blindly. Now the YAML wrappers check project dependencies to determine the correct framework.Import detection still takes priority over
targetFramework, so a TestNG file in a JUnit 5 project still gets TestNG treatment.Test plan
targetFrameworkfallback when file has no framework importstargetFramework