Skip to content

Add mockito-junit-jupiter when PowerMockRunner becomes MockitoExtension - #1185

Merged
timtebeek merged 1 commit into
mainfrom
tim/powermock-mockito-dependency-fix
Oct 12, 2026
Merged

timtebeek merged 1 commit into
mainfrom
tim/powermock-mockito-dependency-fix

Conversation

@timtebeek

Copy link
Copy Markdown
Member

UseMockitoExtension only added mockito-junit-jupiter when its scanner saw a MockitoJUnit*Runner, but in PowerMock projects ReplacePowerMockito rewrites @RunWith(PowerMockRunner.class) to MockitoJUnitRunner.Silent and then @ExtendWith(MockitoExtension.class) within the same cycle, so the dependency was never added (seen in five Capital One repositories).
This adds a second AddDependency keyed on org.powermock.modules.junit4.PowerMockRunner; keying it on org.mockito.junit.jupiter..* instead would rely on a second cycle that does not happen when mockito-core is already declared.
The regression test runs JUnit4to5Migration with production cycle limits (recipe.run(sources, ctx, 3, 1)) and asserts the resulting pom, which now matches what a plain MockitoJUnitRunner project gets.

UseMockitoExtension only added mockito-junit-jupiter when the scanner saw a
MockitoJUnit*Runner, but in PowerMock projects ReplacePowerMockito turns
PowerMockRunner into MockitoJUnitRunner.Silent in the same cycle, so the
dependency was never added within the cycles a production run performs.
@timtebeek
timtebeek merged commit 8082590 into main Oct 12, 2026
1 check passed
@timtebeek
timtebeek deleted the tim/powermock-mockito-dependency-fix branch October 12, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant