GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Re-include CloseUnclosedStaticMocks in Mockito1to4Migration by steve-aom-elliott · Pull Request #1019 · openrewrite/rewrite-testing-frameworks

Conversation

@steve-aom-elliott

@steve-aom-elliott steve-aom-elliott commented Jun 15, 2026 •
edited by moderne-meeseeks Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

What's changed?

Re-enables CloseUnclosedStaticMocks inside the Mockito1to4Migration composite recipe.

What's your motivation?

  • CloseUnclosedStaticMocks was added to Mockito1to4Migration in Recipe for closing unclosed static mocks #739 so users wouldn't need to seek it out separately, then commented out two days later in d1e6bbb after @timtebeek observed it injecting teardown in the wrong scope for @Nested classes — e.g. JMockitMockUpToMockitoTest.mockUpAtSetUpWithTearDownTest() (see the discussion on #739).

  • CloseUnclosedStaticMocks: Handle Nested class, qualifiedclass name. #742 (merged two days after the comment-out) handled nested classes and qualified mocked-class names, fixing the underlying issue. The YAML line was never re-enabled — appears to have been an oversight rather than a remaining concern.

Verification

Locally green:

  • JMockitMockUpToMockitoTest (the canary @timtebeek originally pointed at)
  • CloseUnclosedStaticMocksTest
  • Mockito1to3MigrationTest, Mockito1to4MigrationTest, Mockito1to5MigrationTest
  • Full org.openrewrite.java.testing.mockito.* and org.openrewrite.java.testing.jmockit.* packages
  • recipeCsvValidate (both completeness and content)

Checklist

  • I've added unit tests to cover both positive and negative cases (covered by existing CloseUnclosedStaticMocksTest and the composite migration tests)
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@steve-aom-elliott
Re-include CloseUnclosedStaticMocks in Mockito1to4Migration
dc4c9a3
Disabled in d1e6bbb after teardown was injected in the wrong scope for
@nested classes; #742 fixed nested-class and qualified-class-name
handling. Re-enabling now that the underlying issue is resolved.
@steve-aom-elliott
steve-aom-elliott requested a review from timtebeek June 15, 2026 15:51
@steve-aom-elliott steve-aom-elliott self-assigned this Jun 15, 2026
@steve-aom-elliott steve-aom-elliott added enhancement New feature or request recipe Recipe request labels Jun 15, 2026
@steve-aom-elliott steve-aom-elliott added this to OpenRewrite Jun 15, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jun 15, 2026
@steve-aom-elliott steve-aom-elliott moved this from In Progress to Ready to Review in OpenRewrite Jun 15, 2026
@steve-aom-elliott

steve-aom-elliott commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

CI failure here is pre-existing on main and unrelated to this change.

  • Failing test: org.openrewrite.java.testing.junit5.UpdateMockWebServerMockResponseTest.shouldMigrateMockResponseToBuilder()
  • Recipe under test: UpdateMockWebServerMockResponse — has nothing to do with Mockito1to4Migration or CloseUnclosedStaticMocks.
  • Repro on main with no diff applied: ./gradlew test --tests 'org.openrewrite.java.testing.junit5.UpdateMockWebServerMockResponseTest.shouldMigrateMockResponseToBuilder' → FAILED locally on main at e1cb8925.

The reason it's been green on main push runs is that Gradle's :test task is UP-TO-DATE when nothing it touches has changed — the broken assertion just never gets re-evaluated. Push runs on main complete in ~2m vs. ~10m for PR runs, which fits that pattern. This PR forced a fresh test run and surfaced the latent failure.

The expected vs. actual diff:

-    private Builder mockResponse = new MockResponse.Builder()
+    private MockResponse.Builder mockResponse = new MockResponse.Builder()

…plus removal of the import mockwebserver3.MockResponse.Builder; line. Looks like import-shortening / inner-class handling has shifted in a dependency or the recipe itself since this test was written.

Happy to file a separate issue for that test if useful — but it shouldn't block this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

timtebeek
timtebeek approved these changes Jun 15, 2026
View reviewed changes
@timtebeek
timtebeek merged commit 45342dc into main Jun 15, 2026
1 check failed

Uh oh!

There was an error while loading. Please reload this page.

@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Jun 15, 2026
@timtebeek
timtebeek deleted the reenable-close-unclosed-static-mocks branch June 15, 2026 16:17
mergify Bot added a commit to robfrank/linklift that referenced this pull request Jun 18, 2026
@mergify
chore(deps): bump org.openrewrite.recipe:rewrite-testing-frameworks f…
c8e8db1
…rom 3.37.0 to 3.38.0 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-testing-frameworks](https://github.com/openrewrite/rewrite-testing-frameworks) from 3.37.0 to 3.38.0.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-testing-frameworks's releases](https://github.com/openrewrite/rewrite-testing-frameworks/releases).*

> 3.38.0
> ------
>
> What's Changed
> --------------
>
> * Don't add MockitoExtension during migration when unsafe ([#875](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/875)) by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1017](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1017)
> * Add junit-platform-launcher testRuntimeOnly dependency for Gradle during JUnit 6 migration by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1018](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1018)
> * Migrate removed LocalStack Service enum and getEndpointOverride in Testcontainers 2.x migration by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-testing-frameworks#1014](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1014)
> * Re-include CloseUnclosedStaticMocks in Mockito1to4Migration by [`@​steve-aom-elliott`](https://github.com/steve-aom-elliott) in [openrewrite/rewrite-testing-frameworks#1019](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1019)
> * Update MockWebServer MockResponse test for nested-type render change by [`@​steve-aom-elliott`](https://github.com/steve-aom-elliott) in [openrewrite/rewrite-testing-frameworks#1020](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1020)
> * Fix UsesType precondition pattern in KotlinTestMethodsShouldReturnUnit by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1022](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1022)
> * Support 4-arg Whitebox.setInternalState(target, field, value, Class) by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-testing-frameworks#1023](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1023)
> * Refactor `PowerMockWhiteboxToJavaReflection` into per-API recipes by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-testing-frameworks#1021](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1021)
> * Box primitive casts in `Whitebox.getInternalState`/`invokeMethod` reflection by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-testing-frameworks#1024](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1024)
>
> **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.37.0...v3.38.0>


Commits

* [`862bd49`](openrewrite/rewrite-testing-frameworks@862bd49) Box primitive casts in Whitebox getInternalState/invokeMethod reflection ([#1024](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1024))
* [`9e86af9`](openrewrite/rewrite-testing-frameworks@9e86af9) Refactor `PowerMockWhiteboxToJavaReflection` into per-API recipes ([#1021](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1021))
* [`30c392d`](openrewrite/rewrite-testing-frameworks@30c392d) Support 4-arg Whitebox.setInternalState(target, field, value, Class) ([#1023](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1023))
* [`c9cd3bd`](openrewrite/rewrite-testing-frameworks@c9cd3bd) Fix UsesType precondition pattern in KotlinTestMethodsShouldReturnUnit ([#1022](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1022))
* [`a602b44`](openrewrite/rewrite-testing-frameworks@a602b44) OpenRewrite recipe best practices
* [`ff368ff`](openrewrite/rewrite-testing-frameworks@ff368ff) Update UpdateMockWebServerMockResponse test for nested-type render change ([#1](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1)...
* [`45342dc`](openrewrite/rewrite-testing-frameworks@45342dc) Re-include CloseUnclosedStaticMocks in Mockito1to4Migration ([#1019](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1019))
* [`e1cb892`](openrewrite/rewrite-testing-frameworks@e1cb892) Migrate removed LocalStack `Service` enum and `getEndpointOverride` in Testco...
* [`3934d1e`](openrewrite/rewrite-testing-frameworks@3934d1e) Add junit-platform-launcher testRuntimeOnly dependency for Gradle during JUni...
* [`d5554a9`](openrewrite/rewrite-testing-frameworks@d5554a9) Don't add MockitoExtension during migration when unsafe ([#875](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/875)) ([#1017](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1017))
* Additional commits viewable in [compare view](openrewrite/rewrite-testing-frameworks@v3.37.0...v3.38.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@timtebeek timtebeek timtebeek approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@steve-aom-elliott steve-aom-elliott

Labels

enhancement New feature or request recipe Recipe request

Projects

OpenRewrite
Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@steve-aom-elliott @timtebeek
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.