Skip to content

Run the full Cucumber-JVM 7.x upgrade from JUnit4to5Migration - #1181

Merged
timtebeek merged 2 commits into
mainfrom
tim/cucumber-upgradecucumber7x-review
Oct 9, 2026
Merged

timtebeek merged 2 commits into
mainfrom
tim/cucumber-upgradecucumber7x-review

Conversation

@timtebeek

@timtebeek timtebeek commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

#1178 had JUnit4to5Migration run CucumberToJunitPlatformSuite, which only converts the io.cucumber.junit.Cucumber runner. Tests still on the cucumber.api.junit.Cucumber runner, which Cucumber-JVM removed in 5.0, kept it after junit:junit was removed, so they still failed to compile.

The migration now runs UpgradeCucumber7x, which moves the cucumber.api types to io.cucumber and then runs the same suite migration. Since openrewrite/rewrite-cucumber-jvm#69, that suite migration also moves all Cucumber-JVM dependencies to 7.x, so the code migrations in UpgradeCucumber7x need to come along.

cucumber4RunnerBecomesSuite covers a Cucumber-JVM 4.8.1 runner and its pom. It adds cucumber-core and cucumber-junit 4.8.1 to the test type table.

Closes openrewrite/rewrite-cucumber-jvm#1: running JUnit4to5Migration now migrates a Cucumber project from JUnit 4 to JUnit 5, covering the runner and the rest of the JUnit 4 usage, so rewrite-cucumber-jvm need not depend on rewrite-testing-frameworks as that issue proposed.

`CucumberToJunitPlatformSuite` only converts the `io.cucumber.junit.Cucumber` runner,
so the `cucumber.api.junit.Cucumber` runner of Cucumber-JVM 4.x and earlier was left
in place once `junit:junit` was removed. `UpgradeCucumber7x` first moves those types
to `io.cucumber` and the dependencies to 7.x, and ends with the suite migration.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Oct 9, 2026
timtebeek added a commit to openrewrite/rewrite-cucumber-jvm that referenced this pull request Oct 9, 2026
`JUnit4to5Migration` is to run `UpgradeCucumber7x` rather than only
`CucumberToJunitPlatformSuite` (openrewrite/rewrite-testing-frameworks#1181),
so the suite migration no longer needs to hold back on modules below 7.x.
`CucumberToJunitPlatformSuite` again migrates the runner and swaps the
dependency wherever it runs, still moving the rest of the Cucumber-JVM
dependencies along to the same 7.x.
timtebeek added a commit to openrewrite/rewrite-cucumber-jvm that referenced this pull request Oct 9, 2026
* Keep the cucumber-junit-platform-engine swap resolvable

The swap of `cucumber-junit` for `cucumber-junit-platform-engine` in
`CucumberToJunitPlatformSuite` carried over the old version, which does not exist
before 5.0.0, and left the engine without a version where a parent managed
`cucumber-junit`. Either way Maven could no longer read the pom.

- The engine now moves to 7.x, adding a version only where nothing manages it.
- The rest of the Cucumber-JVM dependencies move to that same 7.x, as the
  engine fails to run against a `cucumber-core` of any other release.
- On its own, as from `JUnit4to5Migration`, the JUnit 4 runner is only migrated
  in modules already on Cucumber-JVM 7.x; `UpgradeCucumber7x` still migrates it
  from any version.
- `junit-platform-suite` is also added for the `cucumber.api` runner, which
  `UpgradeCucumber7x` renames and migrates in the same run.

* Move a cucumber-bom import before overriding managed versions

With `overrideManagedVersion`, `UpgradeDependencyVersion` looks for the release of
an importing BOM that manages each dependency at the target version, downloading
one `cucumber-bom` pom after another. Moving the import to the latest 7.x first
leaves nothing newer to look for.

* Drop the Cucumber-JVM 7.x gate on the JUnit 4 runner migration

`JUnit4to5Migration` is to run `UpgradeCucumber7x` rather than only
`CucumberToJunitPlatformSuite` (openrewrite/rewrite-testing-frameworks#1181),
so the suite migration no longer needs to hold back on modules below 7.x.
`CucumberToJunitPlatformSuite` again migrates the runner and swaps the
dependency wherever it runs, still moving the rest of the Cucumber-JVM
dependencies along to the same 7.x.

* Condense the CucumberToJunitPlatformSuite tests to one per pom shape
@timtebeek
timtebeek marked this pull request as ready for review October 9, 2026 15:03
@timtebeek
timtebeek merged commit 9ae2364 into main Oct 9, 2026
1 of 2 checks passed
@timtebeek
timtebeek deleted the tim/cucumber-upgradecucumber7x-review branch October 9, 2026 15: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.

Migrate Cucumber from JUnit 4 to JUnit 5

1 participant