Skip to content

Support autodetected Jupiter extensions in native tests#919

Open
jormundur00 wants to merge 1 commit into
graalvm:masterfrom
jormundur00:rhei/issue-652
Open

Support autodetected Jupiter extensions in native tests#919
jormundur00 wants to merge 1 commit into
graalvm:masterfrom
jormundur00:rhei/issue-652

Conversation

@jormundur00

@jormundur00 jormundur00 commented Jun 9, 2026

Copy link
Copy Markdown
Member

Fixes #652

What changed

This PR adds support for JUnit Jupiter extensions discovered through META-INF/services when junit.jupiter.extensions.autodetection.enabled=true is used in native tests.

Before this change, service-registered Jupiter extensions could be present and autodetection could be enabled, but the extension classes were not registered for native-image reflection.

After this change, service-loaded Jupiter extensions are registered for reflection when autodetection is enabled, so they can participate in native test execution.

Why

Users expect Jupiter extension autodetection to work the same way in native tests as it does in the JVM test path when the required service registration is present.

Example

Before:

A Jupiter extension registered through META-INF/services/org.junit.jupiter.api.extension.Extension could be discovered conceptually, but the native test path would still fail to apply it because the extension class was not prepared for native-image reflection.

After:

The same service-registered extension is reflected into the image and runs successfully when autodetection is enabled.

Implementation summary

  • Register service-loaded org.junit.jupiter.api.extension.Extension provider classes for reflection from JupiterConfigProvider when Jupiter extension autodetection is enabled.
  • Use ServiceLoader.Provider::type so user extensions are not instantiated during image setup.
  • Enable the autodetection flag for the module's JVM and native test paths.
  • Add a service-provider fixture and test proving the auto-detected extension runs.

Validation

  • grund check
  • JAVA_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal ./gradlew --no-daemon :junit-platform-native:checkstyleMain :junit-platform-native:checkstyleTest
  • JAVA_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal ./gradlew --no-daemon :junit-platform-native:test
  • JAVA_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal GRAALVM_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal ./gradlew --no-daemon :junit-platform-native:nativeTest
  • git diff --check

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jun 9, 2026
@jormundur00 jormundur00 marked this pull request as ready for review July 2, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement. rhei

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Registering Junit5 Extensions Automatically

1 participant