Top Description Methods
org.junit.jupiter.api.condition

public @Interface EnabledInNativeImage

extends Annotation
Annotations
@Target:TYPE, METHOD
@Retention:RUNTIME
@Documented
@EnabledIfSystemProperty
named:org.graalvm.nativeimage.imagecode
matches:.+
disabledReason:Not currently executing within a GraalVM native image
@API
status:STABLE
since:5.9.1
Static Imports
org.apiguardian.api.API.Status.STABLE

@EnabledInNativeImage is used to signal that the annotated test class or test method is only enabled when executing within a GraalVM native image.

When applied at the class level, all test methods within that class will be enabled within a native image.

This annotation is not @Inherited. Consequently, if you wish to apply the same semantics to a subclass, this annotation must be redeclared on the subclass.

If a test method is disabled via this annotation, that prevents execution of the test method and method-level lifecycle callbacks such as @BeforeEach methods, @AfterEach methods, and corresponding extension APIs. However, that does not prevent the test class from being instantiated, and it does not prevent the execution of class-level lifecycle callbacks such as @BeforeAll methods, @AfterAll methods, and corresponding extension APIs.

This annotation may be used as a meta-annotation in order to create a custom composed annotation that inherits the semantics of this annotation.

Technical Details

JUnit detects whether tests are executing within a GraalVM native image by checking for the presence of the org.graalvm.nativeimage.imagecode system property (see org.graalvm.nativeimage.ImageInfo for details). The GraalVM compiler sets the property to buildtime while compiling a native image; the property is set to runtime while a native image is executing; and the Gradle and Maven plug-ins in the GraalVM Native Build Tools project set the property to agent while executing tests with the GraalVM tracing agent.

Since
5.9.1
See Also
org.junit.jupiter.api.condition.EnabledIf, org.junit.jupiter.api.condition.DisabledIf, org.junit.jupiter.api.condition.EnabledOnOs, org.junit.jupiter.api.condition.DisabledOnOs, org.junit.jupiter.api.condition.EnabledOnJre, org.junit.jupiter.api.condition.DisabledOnJre, org.junit.jupiter.api.condition.EnabledForJreRange, org.junit.jupiter.api.condition.DisabledForJreRange, org.junit.jupiter.api.condition.DisabledInNativeImage, org.junit.jupiter.api.condition.EnabledIfSystemProperty, org.junit.jupiter.api.condition.DisabledIfSystemProperty, org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable, org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable, org.junit.jupiter.api.Disabled

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString