Skip to content

Only add the Mockito type import when spying statically - #1204

Merged
timtebeek merged 1 commit into
mainfrom
tim/powermockito-test-failed-fix
Oct 21, 2026
Merged

timtebeek merged 1 commit into
mainfrom
tim/powermockito-test-failed-fix

Conversation

@timtebeek

Copy link
Copy Markdown
Member

Restores the spiedStatically guard around maybeAddImport("org.mockito.Mockito") that 18c9f6f removed as redundant. Without it, maybeAddImport counts the statically imported mock(..)/mockStatic(..) calls as references to the Mockito type, so the recipe adds an unused import org.mockito.Mockito; next to import static org.mockito.Mockito.*;. The type import is only needed for the Mockito.mockStatic(.., Mockito.CALLS_REAL_METHODS) template used when spying statically. This fixes PowerMockitoMockStaticToMockitoTest.tearDownMethodOfTestNGHasAnnotationWithSameArgumentsAsTheTestThatCallsMockStatic on main.

@timtebeek timtebeek changed the title Only add the Mockito type import in PowerMockitoMockStaticToMockito when spying statically Only add the Mockito type import when spying statically Oct 21, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Oct 21, 2026
@timtebeek
timtebeek merged commit 21a854e into main Oct 21, 2026
2 checks passed
@timtebeek
timtebeek deleted the tim/powermockito-test-failed-fix branch October 21, 2026 22:45
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant