diff --git a/framework-docs/modules/ROOT/nav.adoc b/framework-docs/modules/ROOT/nav.adoc index 37cb971836c..9dd9bcd2d24 100644 --- a/framework-docs/modules/ROOT/nav.adoc +++ b/framework-docs/modules/ROOT/nav.adoc @@ -182,6 +182,7 @@ ***** xref:testing/annotations/integration-spring/annotation-sqlconfig.adoc[] ***** xref:testing/annotations/integration-spring/annotation-sqlmergemode.adoc[] ***** xref:testing/annotations/integration-spring/annotation-sqlgroup.adoc[] +***** xref:testing/annotations/integration-spring/annotation-disabledinaotmode.adoc[] **** xref:testing/annotations/integration-junit4.adoc[] **** xref:testing/annotations/integration-junit-jupiter.adoc[] **** xref:testing/annotations/integration-meta.adoc[] diff --git a/framework-docs/modules/ROOT/pages/testing/annotations/integration-junit-jupiter.adoc b/framework-docs/modules/ROOT/pages/testing/annotations/integration-junit-jupiter.adoc index e9cd1e17679..3bc6e18d1a2 100644 --- a/framework-docs/modules/ROOT/pages/testing/annotations/integration-junit-jupiter.adoc +++ b/framework-docs/modules/ROOT/pages/testing/annotations/integration-junit-jupiter.adoc @@ -11,6 +11,7 @@ xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupite * xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-nestedtestconfiguration[`@NestedTestConfiguration`] * xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-junit-jupiter-enabledif[`@EnabledIf`] * xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-junit-jupiter-disabledif[`@DisabledIf`] +* xref:testing/annotations/integration-spring/annotation-disabledinaotmode.adoc[`@DisabledInAotMode`] [[integration-testing-annotations-junit-jupiter-springjunitconfig]] == `@SpringJUnitConfig` diff --git a/framework-docs/modules/ROOT/pages/testing/annotations/integration-spring.adoc b/framework-docs/modules/ROOT/pages/testing/annotations/integration-spring.adoc index 45faf7965d4..3804efbc56f 100644 --- a/framework-docs/modules/ROOT/pages/testing/annotations/integration-spring.adoc +++ b/framework-docs/modules/ROOT/pages/testing/annotations/integration-spring.adoc @@ -27,4 +27,5 @@ Spring's testing annotations include the following: * xref:testing/annotations/integration-spring/annotation-sqlconfig.adoc[`@SqlConfig`] * xref:testing/annotations/integration-spring/annotation-sqlmergemode.adoc[`@SqlMergeMode`] * xref:testing/annotations/integration-spring/annotation-sqlgroup.adoc[`@SqlGroup`] +* xref:testing/annotations/integration-spring/annotation-disabledinaotmode.adoc[`@DisabledInAotMode`] diff --git a/framework-docs/modules/ROOT/pages/testing/annotations/integration-spring/annotation-disabledinaotmode.adoc b/framework-docs/modules/ROOT/pages/testing/annotations/integration-spring/annotation-disabledinaotmode.adoc new file mode 100644 index 00000000000..2fbfc6a19b3 --- /dev/null +++ b/framework-docs/modules/ROOT/pages/testing/annotations/integration-spring/annotation-disabledinaotmode.adoc @@ -0,0 +1,20 @@ +[[spring-testing-annotation-disabledinaotmode]] += `@DisabledInAotMode` + +`@DisabledInAotMode` signals that an annotated test class is disabled in Spring AOT +(ahead-of-time) mode, which means that the `ApplicationContext` for the test class will +not be processed for AOT optimizations at build time. + +If a test class is annotated with `@DisabledInAotMode`, all other test classes which +specify configuration to load the same `ApplicationContext` must also be annotated with +`@DisabledInAotMode`. Failure to annotate all such test classes will result in an +exception, either at build time or run time. + +When used with JUnit Jupiter based tests, `@DisabledInAotMode` also signals that the +annotated test class or test method is disabled when running the test suite in Spring AOT +mode. When applied at the class level, all test methods within that class will be +disabled. In this sense, `@DisabledInAotMode` has semantics similar to those of JUnit +Jupiter's `@DisabledInNativeImage` annotation. + +For details on AOT support specific to integration tests, see +xref:testing/testcontext-framework/aot.adoc[Ahead of Time Support for Tests]. diff --git a/framework-docs/modules/ROOT/pages/testing/testcontext-framework/aot.adoc b/framework-docs/modules/ROOT/pages/testing/testcontext-framework/aot.adoc index c9836157b55..0ce800ca227 100644 --- a/framework-docs/modules/ROOT/pages/testing/testcontext-framework/aot.adoc +++ b/framework-docs/modules/ROOT/pages/testing/testcontext-framework/aot.adoc @@ -19,6 +19,15 @@ following features. use an AOT-optimized `ApplicationContext` that participates transparently with the xref:testing/testcontext-framework/ctx-management/caching.adoc[context cache]. +All tests are enabled in AOT mode by default. However, you can selectively disable an +entire test class or individual test method in AOT mode by annotating it with +xref:testing/annotations/integration-spring/annotation-disabledinaotmode.adoc[`@DisabledInAotMode`]. +When using JUnit Jupiter, you may selectively enable or disable tests in a GraalVM native +image via Jupiter's `@EnabledInNativeImage` and `@DisabledInNativeImage` annotations. +Note that `@DisabledInAotMode` also disables the annotated test class or test method when +running within a GraalVM native image, analogous to JUnit Jupiter's +`@DisabledInNativeImage` annotation. + [TIP] ==== By default, if an error is encountered during build-time AOT processing, an exception