Skip to content

Bump JUnit Platform to 6.0.3 for JUnit 6 unified versioning#114

Open
clara-deadline wants to merge 1 commit intopitest:masterfrom
clara-deadline:junit-platform-6.x-support
Open

Bump JUnit Platform to 6.0.3 for JUnit 6 unified versioning#114
clara-deadline wants to merge 1 commit intopitest:masterfrom
clara-deadline:junit-platform-6.x-support

Conversation

@clara-deadline
Copy link
Copy Markdown

@clara-deadline clara-deadline commented Apr 12, 2026

Problem

JUnit 6.0.0 shipped with unified versioning — all artifacts (Platform, Jupiter, Vintage) now share the same 6.0.x version. Spring Boot 4.0.5 ships junit-platform-launcher:6.0.3 via its BOM.

Projects on Spring Boot 4 get 0% coverage and 0 tests per mutation because the plugin's shaded JUnit Platform classes (1.9.2) don't match the 6.0.3 runtime on the classpath.

Detailed reproduction in #113.

Changes

Property Old New
junit.platform.version 1.9.2 6.0.3
junit.version 5.9.2 6.0.3
maven.compiler.source/target 1.8 17

Why this should work

The JUnit Platform Launcher API used by this plugin (Launcher, LauncherFactory, DiscoverySelectors, TestExecutionListener, TestIdentifier, TagFilter, MethodSource, etc.) is unchanged between Platform 1.9.2 and 6.0.3. JUnit 6 is a re-versioning with cleanup (Java 17+ baseline, JSpecify annotations, removed JUnit 4 runner bridge), not a rewrite.

The five source files in src/main/java (386 total lines) compile cleanly against Platform 6.0.3 with zero source changes.

Known gaps

  • Test dependencies: Cucumber 5.0.0 and Spock 2.3-groovy-4.0 may need bumping to versions that support JUnit Platform 6.x. I didn't update them here to keep the diff focused on the core change.
  • CI: The project's GitHub Actions workflow may need a JDK 17+ runner (JUnit 6 requires Java 17+).

Impact

This unblocks mutation testing for every project on Spring Boot 4+, which is the current GA release. Without this fix, PIT cannot be used with Spring Boot 4.

Fixes #113

Workaround for users waiting for this to merge

If you need pitest working now on Spring Boot 4 + JUnit 6, you can unblock yourself with three changes in your build.gradle.kts:

  1. Add JUnit Platform 6.0.3 to the pitest configuration (launch classpath) so PIT sees the same JUnit Platform version as your test runtime.
  2. Set the PIT launcher JVM to JDK 25 via javaLauncher on the PitestTask, since JUnit 6 requires Java 17+ and your project may already be on 25.
  3. Exclude integration tests that need Docker (e.g. Testcontainers) since PIT runs tests in a forked JVM without Docker networking.
// build.gradle.kts

plugins {
    id("info.solidsoft.pitest") version "1.15.0"
}

// 1. Put JUnit Platform 6.0.3 on the pitest launch classpath
dependencies {
    pitest("org.junit.platform:junit-platform-launcher:6.0.3")
    pitest("org.junit.jupiter:junit-jupiter-api:6.0.3")
    pitest("org.junit.jupiter:junit-jupiter-engine:6.0.3")
}

pitest {
    junit5PluginVersion.set("1.2.1")      // latest release of this plugin
    pitestVersion.set("1.17.4")           // latest PIT
    targetClasses.set(listOf("com.example.*"))
    excludedTestClasses.set(listOf(
        // 3. Exclude integration tests that require Docker / Testcontainers
        "*IntegrationTest",
        "*IT"
    ))
    threads.set(4)
    outputFormats.set(listOf("HTML", "XML"))
    timestampedReports.set(false)
}

// 2. Point the PIT forked JVM at JDK 25 so JUnit 6 class files load
tasks.withType<info.solidsoft.pitest.PitestTask>() {
    javaLauncher.set(
        javaToolchains.launcherFor {
            languageVersion.set(JavaLanguageVersion.of(25))
        }
    )
}

The key insight is that pitest(...) dependencies go on PIT's own classpath (the forked JVM that discovers and runs tests), which is separate from your project's testImplementation classpath. Without these, PIT launches with the plugin's shaded Platform 1.9.2, which cannot load JUnit 6 test classes.

JUnit 6.0.0 shipped with unified versioning — all artifacts (Platform,
Jupiter, Vintage) now share the same 6.0.x version number. What was
previously junit-platform-engine:1.9.2 is now junit-platform-engine:6.0.3.

Spring Boot 4.0.5 ships JUnit Platform 6.0.3 via its BOM. Projects on
Spring Boot 4 cannot use the current pitest-junit5-plugin because the
platform version mismatch causes the coverage analysis phase to find 0%
coverage and run 0 tests per mutation (see issue pitest#113).

Changes:
- junit.platform.version: 1.9.2 -> 6.0.3
- junit.version: 5.9.2 -> 6.0.3 (unified versioning)
- maven.compiler.source/target: 1.8 -> 17 (JUnit 6 requires Java 17+)

The JUnit Platform Launcher API (Launcher, LauncherFactory,
DiscoverySelectors, TestExecutionListener, etc.) used by this plugin
is unchanged between Platform 1.9.2 and 6.0.3 — JUnit 6 is a
re-versioning with cleanup, not a rewrite.

Note: test dependencies (Cucumber 5.0.0, Spock 2.3) may need bumping
to versions that support JUnit Platform 6.x. This PR focuses on the
core compile-time change; test dep updates can follow.

Fixes pitest#113
@hcoles
Copy link
Copy Markdown
Contributor

hcoles commented Apr 12, 2026

@clara-deadline

Thanks for the PR.

It looks like this PR may have been created using an LLM.

Can you please confirm

  1. That a human has verified that described issue exists
  2. That a human has confirmed that the changes in this PR fix the issue
  3. That a human has confirmed that the change does not break projects using JUnit5

Please also provide a link to a minimal project that demonstrates the problem.

Thanks

Henry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support JUnit Platform 6.0.x (unified versioning from JUnit 6)

2 participants