Skip to content

Upgrade WireMock to the latest 2.x in JUnit4to5Migration - #1182

Merged
timtebeek merged 3 commits into
mainfrom
tim/wiremockextension-upgrade
Oct 9, 2026
Merged

timtebeek merged 3 commits into
mainfrom
tim/wiremockextension-upgrade

Conversation

@timtebeek

@timtebeek timtebeek commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

UseWiremockExtension (part of JUnit4to5Migration) rewrites WireMockRule to com.github.tomakehurst.wiremock.junit5.WireMockExtension, which only exists from WireMock 2.31.0. Its nested upgrade of com.github.tomakehurst:wiremock* to 2.x could not help modules on com.github.tomakehurst:wiremock or wiremock-standalone: both end at 2.27.2, and the 2.x line continues on Java 8 only as wiremock-jre8 / wiremock-jre8-standalone (up to 2.35.2). Those modules then failed testCompile with package com.github.tomakehurst.wiremock.junit5 does not exist.

This replaces the Java getRecipeList() with declarative steps in JUnit4to5Migration, right after UseWiremockExtension:

  • ChangeDependency wiremock โ†’ wiremock-jre8 and wiremock-standalone โ†’ wiremock-jre8-standalone, both at 2.x. The group stays com.github.tomakehurst.
  • UpgradeDependencyVersion com.github.tomakehurst:wiremock* to 2.x, with overrideManagedVersion: true.

Nothing moves to org.wiremock 3.x, which needs Java 11.

Tests run the full JUnit4to5Migration on Maven projects with:

  • wiremock-jre8 2.27.2 and 2.31.0
  • wiremock 2.27.2 and wiremock-standalone 2.27.2
  • a version managed by an in-repo parent's dependencyManagement
  • a version set by an external parent's property (spring-cloud-contract-dependencies 3.0.0, which overrides wiremock.version)

JUnit5to6Migration drops the -jre8 artifacts again: it already ends with UpgradeWiremockDependencyVersion, which moves every com.github.tomakehurst WireMock artifact to org.wiremock 3.x (Java 11+). A test runs JUnit4to5Migration and JUnit5to6Migration together, as Spring Boot 4's upgrade does: wiremock 2.27.2 ends on org.wiremock:wiremock 3.x. Outside this repo, a WireMockExtension test passed on JUnit 6.1.3 with org.wiremock:wiremock and wiremock-standalone 3.13.2, and with wiremock-jre8 and wiremock-jre8-standalone 2.35.2.

WireMockExtension only exists from WireMock 2.31.0, but com.github.tomakehurst:wiremock and wiremock-standalone end at 2.27.2, so the existing upgrade to 2.x left those modules without it. Move them to wiremock-jre8 and wiremock-jre8-standalone, which continue the 2.x line on Java 8, and upgrade all com.github.tomakehurst WireMock artifacts to the latest 2.x through declarative steps in JUnit4to5Migration.
Spring Boot 4 runs JUnit4to5Migration and JUnit5to6Migration in one run, so the wiremock-jre8 dependency from the former must end up on org.wiremock:wiremock 3.x through UpgradeWiremockDependencyVersion in the latter.
@timtebeek
timtebeek merged commit f05953a into main Oct 9, 2026
1 check passed
@timtebeek
timtebeek deleted the tim/wiremockextension-upgrade branch October 9, 2026 17:10
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 9, 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