Skip to content

Re-include CloseUnclosedStaticMocks in Mockito1to4Migration#1019

Merged
timtebeek merged 1 commit into
mainfrom
reenable-close-unclosed-static-mocks
Jun 15, 2026
Merged

Re-include CloseUnclosedStaticMocks in Mockito1to4Migration#1019
timtebeek merged 1 commit into
mainfrom
reenable-close-unclosed-static-mocks

Conversation

@steve-aom-elliott

@steve-aom-elliott steve-aom-elliott commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What's changed?

Re-enables CloseUnclosedStaticMocks inside the Mockito1to4Migration composite recipe.

What's your motivation?

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

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 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
@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

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.

@timtebeek timtebeek merged commit 45342dc into main Jun 15, 2026
1 check failed
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request recipe Recipe request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants