Skip to content

Keep WireMockRule used as a server a WireMockServer; port() to getPort() - #1187

Merged
timtebeek merged 5 commits into
mainfrom
tim/wiremockrule-methods-migrate
Oct 12, 2026
Merged

timtebeek merged 5 commits into
mainfrom
tim/wiremockrule-methods-migrate

Conversation

@timtebeek

Copy link
Copy Markdown
Member

UseWiremockExtension turns every WireMockRule into a WireMockExtension, which breaks tests that call start(), stop(), isRunning() or port() on it, as WireMockRule extends WireMockServer.
The new WireMockRuleToWireMockServer recipe, run before it in JUnit4to5Migration, keeps a rule that is used with server lifecycle methods or passed on as a WireMockServer as a plain WireMockServer, started and stopped in @BeforeEach/@AfterEach (or static @BeforeAll/@AfterAll for a @ClassRule), reusing existing lifecycle methods where present.
It scans all sources, so a rule declared in a base class and stopped in a subclass is caught as well.
UseWiremockExtension now also rewrites port() and httpsPort() on the remaining rules to getPort() and getHttpsPort().
Tests cover both paths, standalone and through JUnit4to5Migration.

@timtebeek
timtebeek merged commit 1ae3400 into main Oct 12, 2026
1 check passed
@timtebeek
timtebeek deleted the tim/wiremockrule-methods-migrate branch October 12, 2026 16:35
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 12, 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