Skip to content

Add the launcher Spring Boot manages in a Spring Boot Gradle build - #1350

Open
krlittle wants to merge 1 commit into
mainfrom
junit-platform-launcher-managed-by-spring-boot
Open

krlittle wants to merge 1 commit into
mainfrom
junit-platform-launcher-managed-by-spring-boot

Conversation

@krlittle

Copy link
Copy Markdown
Contributor

What's changed

JUnit4to5Migration now adds org.junit.platform:junit-platform-launcher without a version to a Gradle build that applies the Spring Boot and Spring dependency management plugins, as Spring Initializr does. Spring Boot then manages the launcher at the JUnit Platform version it manages for the Jupiter engine.

The new declarative recipe AddJUnitPlatformLauncherManagedBySpringBoot runs just before the existing AddDependency that adds the launcher at 1.x. That one then skips the build, because the configuration already requests the launcher. Builds without those two plugins get the launcher as before.

What's your motivation?

In a Spring Boot build, version: 1.x picks the newest launcher, 1.14.4, while Spring Boot 3.5 manages JUnit Platform 1.12. The tests can't start:

NoClassDefFoundError: org/junit/platform/engine/OutputDirectoryCreator

The public repository UKHomeOffice/hocs-workflow ran 919 tests before its migration to Spring Boot 3.5. After the migration it got testRuntimeOnly "org.junit.platform:junit-platform-launcher:1.14.4" and ran none. With the launcher left versionless, all 919 tests run again.

Any additional context

  • JUnit5MigrationTest.springBootGradleBuildGetsTheLauncherSpringBootManages fails without the change to junit5.yml, where the launcher gets :1.14.4, and passes with it.
  • JUnit5MigrationTest passes in full (30 tests). I didn't run the rest of the suite.
  • recipes.csv gets the new recipe's row and +3 on the counts of the four recipes that include it. Running recipeCsvGenerate locally also changed unrelated rows, because local dependency versions differ, so I left those out. recipeCsvValidate passes.

JUnit4to5Migration added junit-platform-launcher at the newest 1.x, which
in a Spring Boot build is newer than the JUnit Platform that Spring Boot
manages, and the tests then can't start. Where the Spring Boot and Spring
dependency management plugins are applied, the launcher is now added
without a version, so Spring Boot manages it, as Spring Initializr does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant