From 0f25c75b9e4a1c2f3385044bcf0183241be30c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Basl=C3=A9?= Date: Thu, 10 Oct 2024 16:27:37 +0200 Subject: [PATCH] Document `TestExecutionListener` implementations introduced in 6.2 Closes gh-33661 --- .../pages/testing/testcontext-framework/tel-config.adoc | 3 +++ .../test/context/TestExecutionListener.java | 8 ++++++++ .../test/context/TestExecutionListeners.java | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/framework-docs/modules/ROOT/pages/testing/testcontext-framework/tel-config.adoc b/framework-docs/modules/ROOT/pages/testing/testcontext-framework/tel-config.adoc index 8c365ba256..bb7f79e808 100644 --- a/framework-docs/modules/ROOT/pages/testing/testcontext-framework/tel-config.adoc +++ b/framework-docs/modules/ROOT/pages/testing/testcontext-framework/tel-config.adoc @@ -10,6 +10,7 @@ by default, exactly in the following order: annotation for "`before`" modes. * `ApplicationEventsTestExecutionListener`: Provides support for xref:testing/testcontext-framework/application-events.adoc[`ApplicationEvents`]. +* `MockitoTestExecutionListener`: Initializes and closes mocks configured using `@MockitoBean` or `@MockitoSpyBean`. * `DependencyInjectionTestExecutionListener`: Provides dependency injection for the test instance. * `MicrometerObservationRegistryTestExecutionListener`: Provides support for @@ -24,6 +25,8 @@ by default, exactly in the following order: annotation. * `EventPublishingTestExecutionListener`: Publishes test execution events to the test's `ApplicationContext` (see xref:testing/testcontext-framework/test-execution-events.adoc[Test Execution Events]). +* `MockitoResetTestExecutionListener`: Resets mocks as configured by `@MockitoBean` or `@MockitoSpyBean`. +* `BeanOverrideTestExecutionListener`: Provides support for xref:testing/testcontext-framework/bean-overriding.adoc[] . [[testcontext-tel-config-registering-tels]] == Registering `TestExecutionListener` Implementations diff --git a/spring-test/src/main/java/org/springframework/test/context/TestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/TestExecutionListener.java index 57fcb43937..e5e85b8209 100644 --- a/spring-test/src/main/java/org/springframework/test/context/TestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/TestExecutionListener.java @@ -66,18 +66,26 @@ package org.springframework.test.context; * DirtiesContextBeforeModesTestExecutionListener} *
  • {@link org.springframework.test.context.event.ApplicationEventsTestExecutionListener * ApplicationEventsTestExecutionListener}
  • + *
  • {@link org.springframework.test.context.bean.override.mockito.MockitoTestExecutionListener + * MockitoTestExecutionListener}
  • *
  • {@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener * DependencyInjectionTestExecutionListener}
  • *
  • {@link org.springframework.test.context.observation.MicrometerObservationRegistryTestExecutionListener * MicrometerObservationRegistryTestExecutionListener}
  • *
  • {@link org.springframework.test.context.support.DirtiesContextTestExecutionListener * DirtiesContextTestExecutionListener}
  • + *
  • {@link org.springframework.test.context.support.CommonCachesTestExecutionListener + * CommonCachesTestExecutionListener}
  • *
  • {@link org.springframework.test.context.transaction.TransactionalTestExecutionListener * TransactionalTestExecutionListener}
  • *
  • {@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener * SqlScriptsTestExecutionListener}
  • *
  • {@link org.springframework.test.context.event.EventPublishingTestExecutionListener * EventPublishingTestExecutionListener}
  • + *
  • {@link org.springframework.test.context.bean.override.mockito.MockitoResetTestExecutionListener + * MockitoResetTestExecutionListener}
  • + *
  • {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener + * BeanOverrideTestExecutionListener}
  • * * * @author Sam Brannen diff --git a/spring-test/src/main/java/org/springframework/test/context/TestExecutionListeners.java b/spring-test/src/main/java/org/springframework/test/context/TestExecutionListeners.java index 23b761629a..b63720bb0e 100644 --- a/spring-test/src/main/java/org/springframework/test/context/TestExecutionListeners.java +++ b/spring-test/src/main/java/org/springframework/test/context/TestExecutionListeners.java @@ -82,11 +82,15 @@ public @interface TestExecutionListeners { * @see org.springframework.test.context.web.ServletTestExecutionListener * @see org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener * @see org.springframework.test.context.event.ApplicationEventsTestExecutionListener + * @see org.springframework.test.context.bean.override.mockito.MockitoTestExecutionListener * @see org.springframework.test.context.support.DependencyInjectionTestExecutionListener * @see org.springframework.test.context.support.DirtiesContextTestExecutionListener + * @see org.springframework.test.context.support.CommonCachesTestExecutionListener * @see org.springframework.test.context.transaction.TransactionalTestExecutionListener * @see org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener * @see org.springframework.test.context.event.EventPublishingTestExecutionListener + * @see org.springframework.test.context.bean.override.mockito.MockitoResetTestExecutionListener + * @see org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener */ @AliasFor("value") Class[] listeners() default {};