Skip to content

Configure jvmTest to use the JUnit Platform in kmp-module#724

Merged
alexander-yevsyukov merged 2 commits into
masterfrom
address-logging-audit-finding
Jul 2, 2026
Merged

Configure jvmTest to use the JUnit Platform in kmp-module#724
alexander-yevsyukov merged 2 commits into
masterfrom
address-logging-audit-finding

Conversation

@alexander-yevsyukov

Copy link
Copy Markdown
Contributor

What

Configure the jvmTest task in the kmp-module convention plugin to run on
the JUnit Platform (useJUnitPlatform()) and to apply the shared test-logging
setup (configureLogging()).

Why

The kmp-module convention never applied module-testing, and it could not:
module-testing brings the java-library plugin, which conflicts with the
Kotlin Multiplatform plugin kmp-module is built on. As a result the KMP
jvmTest task was left without useJUnitPlatform().

Without it, Gradle falls back to the legacy JUnit-4 test detector, which
discovers none of a module's JUnit 5 / Kotest *Spec.kt classes. A test
task that discovers nothing still passes — so, for example, the core logging
module's jvmTest reported success in ~1 s while running zero of its 13
*Spec.kt suites. This silent gap was being worked around module-locally in
consumer repositories (e.g. an otel-backend useJUnitPlatform() block); the
proper fix belongs in the shared convention here, which also lets those local
workarounds be deleted.

How

Mirror module-testing's test-task configuration onto KMP's jvmTest task:

named<Test>("jvmTest") {
    useJUnitPlatform()
    configureLogging()
}

Unlike module-testing, no includeEngines("junit-jupiter") filter is
imposed: KMP test dependencies include Kotest.runnerJUnit5Jvm, a JUnit
Platform engine of its own, and filtering to Jupiter alone would silently drop
Kotest-native tests — re-creating the bug in a subtler form. This rationale is
captured in the task block's KDoc.

Verification

  • ./gradlew -p buildSrc build — PASS (compile, validatePlugins, and
    buildSrc tests all green under JDK 17).
  • Reviewers (spine-code-review, kotlin-engineer, review-docs) — all
    APPROVE, no Must-fix / Should-fix.

🤖 Generated with Claude Code

@alexander-yevsyukov alexander-yevsyukov moved this to 🏗 In progress in v2.0 Jul 1, 2026
@alexander-yevsyukov alexander-yevsyukov self-assigned this Jul 1, 2026
@alexander-yevsyukov alexander-yevsyukov moved this from 🏗 In progress to In Review in v2.0 Jul 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the kmp-module convention plugin to ensure JVM tests in Kotlin Multiplatform modules are executed on the JUnit Platform and receive the standard shared test logging configuration, closing a gap where JUnit 5 / Kotest tests could be silently undiscovered.

Changes:

  • Configure the jvmTest Gradle Test task with useJUnitPlatform().
  • Apply shared test logging via configureLogging() to jvmTest.
  • Document why module-testing can’t be applied and why no engine filter is used (to avoid excluding Kotest’s JUnit Platform engine).

@alexander-yevsyukov alexander-yevsyukov merged commit c2aae6e into master Jul 2, 2026
3 checks passed
@alexander-yevsyukov alexander-yevsyukov deleted the address-logging-audit-finding branch July 2, 2026 11:23
@github-project-automation github-project-automation Bot moved this from In Review to ✅ Done in v2.0 Jul 2, 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.

3 participants