Repository navigation
Pin bare mockito-core type table lookups to a single Mockito major - #1255
Merged
Merged
Conversation
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.
A bare
"mockito-core"type table lookup matches bothmockito-core-3.12.4andmockito-core-5.24.0, so each of these tests parsed against whichever one the lookup happened to pick. This PR qualifies the 20 table lookups in 14 test classes so each one matches exactly one entry. No dependency jar on the test runtime classpath ships a Mockito type table, so the repo's own tables are the only candidates.All tests pass with either version, so the choice is based on what each test exercises:
mockito-core-3is used for recipes inMockito1to3Migration/Mockito1to4Migration(AddMockitoExtensionIfAnnotationsUsed,ThenThrowCheckedExceptionToRuntimeException,AddMockitoJupiterDependency,RemoveInitMocksIfRunnersSpecified,ReplaceInitMockToOpenMock), for the JUnit 4initMocksintegration test, for the PowerMock runner test, and forMockito1to4MigrationTest,Mockito1to5MigrationTestandMockitoBestPracticesTest. The last three migrate a build that declaresmockito-core:3.12.4, so their source should be parsed against 3.mockito-core-5is used for the stand-alone best-practice recipesSimplifyMockitoVerifyWhenGiven,RemoveTimesZeroAndOne,RemoveDoNothingForDefaultMocksandRemoveMockitoSettings.SimplifyMockitoVerifyWhenGivenTestalready usesmockito-core-5in its per-test overrides.CleanupMockitoImportsTestkeepsKotlinParser.builder().classpath("mockito-core", ...). That lookup uses the runtime classpath, which contains onlymockito-core-5.12.0, so it isn't ambiguous.To verify, I ran the 15 affected classes (the 14 changed ones plus
CleanupMockitoImportsTest) with./gradlew --max-workers=2 test --tests ...onmain, on this branch, and with every lookup forced to 3 and then to 5. All four runs gave 148 passed and 4 failed, and the per-test results onmainand this branch were identical. The 4 failures (AddMockitoJupiterDependencyTest.addsMockitoJupiterDependencyWhenMockUsedInJUnit5,Mockito1to4MigrationTest.modifyMockitoDependencies,Mockito1to5MigrationTest.modifyMockitoDependencies,MockitoBestPracticesTest.mockito5) happen in the Gradle tooling API: Maven Central returned HTTP 429 while resolvingorg.openrewrite.gradle.tooling:plugin. They are unrelated to this change, and CI should exercise them.