Repository navigation
Conversation
…5` migrates `mockito-all` The Mockito version upgrade scans the project before `mockito-all` is changed to `mockito-core`, and `mockito-all` has no 5.x, so a version property defined in a parent pom stayed on 1.x while the tests were migrated to Mockito 5 and no longer compiled. A `ChangeDependency` with a `newVersion` raises that property. It runs outside `UpgradeMockito1ForJava25`, whose precondition excludes a parent module that does not declare Mockito itself.
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.
Problem
UpgradeToJava25(throughUpgradeMockito1ForJava25) changesmockito-alltomockito-coreand migrates the test code to Mockito 5. When the version comes from a property defined in a parent pom, as is common in multi-module builds, that property stays on 1.x. The module then depends onmockito-core1.x while its tests use Mockito 5 APIs, so test compilation fails, e.g. withpackage org.mockito.junit does not exist.Before
After (Problem)
After (Expected)
Cause
All scanners of the composite run on the original sources. The Mockito
UpgradeDependencyVersionsteps therefore still seemockito-all, which has no 3.x, 4.x or 5.x release, and never record the property in the parent pom; in the edit phase they only update properties defined in the same pom. The step cannot go intoUpgradeMockito1ForJava25either, as itsModuleHasDependencyprecondition excludes a parent module that declares no Mockito dependency itself.Fix
Add a
ChangeDependencyfrommockito-alltomockito-corewithnewVersion: 5.20.xtoUpgradePluginsForJava25, right afterUpgradeMockito1ForJava25. Its scanner records a version property defined in a parent pom in the project and raises it to the 5.20.x that the followingUpgradeDependencyVersiontargets. Updatedrecipes.csv, and addedraiseMockitoAllVersionPropertyInParenttoUpgradeLegacyMockitoForJava25Test, which fails without the change. An existing Gradlemockito-coreversion variable above 5.20 is not downgraded.