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 ef5f0ab3ca8..815f1940d39 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
@@ -44,8 +44,6 @@ package org.springframework.test.context;
*
Spring provides the following out-of-the-box implementations (all of
* which implement {@code Ordered}):
*
@@ -61,16 +65,8 @@ import org.springframework.test.context.support.AbstractTestExecutionListener;
* support. For further details, consult the class-level Javadoc for
* {@link org.springframework.context.event.EventListener @EventListener}.
*
- * Listener Registration
- * Note that this {@code TestExecutionListener} is not registered by default,
- * but it may be registered for a given test class via
- * {@link org.springframework.test.context.TestExecutionListeners @TestExecutionListeners}
- * or globally via the {@link org.springframework.core.io.support.SpringFactoriesLoader
- * SpringFactoriesLoader} mechanism (consult the Javadoc and Spring reference manual for
- * details).
- *
- * @author Frank Scheffler
* @author Sam Brannen
+ * @author Frank Scheffler
* @since 5.2
* @see org.springframework.test.context.event.annotation.BeforeTestClass @BeforeTestClass
* @see org.springframework.test.context.event.annotation.PrepareTestInstance @PrepareTestInstance
@@ -83,74 +79,80 @@ import org.springframework.test.context.support.AbstractTestExecutionListener;
public class EventPublishingTestExecutionListener extends AbstractTestExecutionListener {
/**
- * Returns {@link Ordered#HIGHEST_PRECEDENCE}.
+ * Returns {@code 10000}.
*/
@Override
- public int getOrder() {
- return Ordered.HIGHEST_PRECEDENCE;
+ public final int getOrder() {
+ return 10_000;
}
/**
- * Publishes a {@link BeforeTestClassEvent} to the {@code ApplicationContext}
+ * Publish a {@link BeforeTestClassEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void beforeTestClass(TestContext testContext) {
- testContext.getApplicationContext().publishEvent(new BeforeTestClassEvent(testContext));
+ publishEvent(testContext, BeforeTestClassEvent::new);
}
/**
- * Publishes a {@link PrepareTestInstanceEvent} to the {@code ApplicationContext}
+ * Publish a {@link PrepareTestInstanceEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void prepareTestInstance(TestContext testContext) {
- testContext.getApplicationContext().publishEvent(new PrepareTestInstanceEvent(testContext));
+ publishEvent(testContext, PrepareTestInstanceEvent::new);
}
/**
- * Publishes a {@link BeforeTestMethodEvent} to the {@code ApplicationContext}
+ * Publish a {@link BeforeTestMethodEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void beforeTestMethod(TestContext testContext) {
- testContext.getApplicationContext().publishEvent(new BeforeTestMethodEvent(testContext));
+ publishEvent(testContext, BeforeTestMethodEvent::new);
}
/**
- * Publishes a {@link BeforeTestExecutionEvent} to the {@code ApplicationContext}
+ * Publish a {@link BeforeTestExecutionEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void beforeTestExecution(TestContext testContext) {
- testContext.getApplicationContext().publishEvent(new BeforeTestExecutionEvent(testContext));
+ publishEvent(testContext, BeforeTestExecutionEvent::new);
}
/**
- * Publishes an {@link AfterTestExecutionEvent} to the {@code ApplicationContext}
+ * Publish an {@link AfterTestExecutionEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void afterTestExecution(TestContext testContext) {
- testContext.getApplicationContext().publishEvent(new AfterTestExecutionEvent(testContext));
+ publishEvent(testContext, AfterTestExecutionEvent::new);
}
/**
- * Publishes an {@link AfterTestMethodEvent} to the {@code ApplicationContext}
+ * Publish an {@link AfterTestMethodEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void afterTestMethod(TestContext testContext) {
- testContext.getApplicationContext().publishEvent(new AfterTestMethodEvent(testContext));
+ publishEvent(testContext, AfterTestMethodEvent::new);
}
/**
- * Publishes an {@link AfterTestClassEvent} to the {@code ApplicationContext}
+ * Publish an {@link AfterTestClassEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void afterTestClass(TestContext testContext) {
- testContext.getApplicationContext().publishEvent(new AfterTestClassEvent(testContext));
+ publishEvent(testContext, AfterTestClassEvent::new);
+ }
+
+ private void publishEvent(TestContext testContext, Function eventFactory) {
+ if (testContext.hasApplicationContext()) {
+ testContext.getApplicationContext().publishEvent(eventFactory.apply(testContext));
+ }
}
}
diff --git a/spring-test/src/main/resources/META-INF/spring.factories b/spring-test/src/main/resources/META-INF/spring.factories
index 30cd85a1820..b28b1e6a245 100644
--- a/spring-test/src/main/resources/META-INF/spring.factories
+++ b/spring-test/src/main/resources/META-INF/spring.factories
@@ -6,7 +6,8 @@ org.springframework.test.context.TestExecutionListener = \
org.springframework.test.context.support.DependencyInjectionTestExecutionListener,\
org.springframework.test.context.support.DirtiesContextTestExecutionListener,\
org.springframework.test.context.transaction.TransactionalTestExecutionListener,\
- org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener
+ org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener,\
+ org.springframework.test.context.event.EventPublishingTestExecutionListener
# Default ContextCustomizerFactory implementations for the Spring TestContext Framework
#
diff --git a/spring-test/src/test/java/org/springframework/test/context/TestExecutionListenersTests.java b/spring-test/src/test/java/org/springframework/test/context/TestExecutionListenersTests.java
index 5356bd1e687..ff1aa9f903e 100644
--- a/spring-test/src/test/java/org/springframework/test/context/TestExecutionListenersTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/TestExecutionListenersTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import org.junit.Test;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationConfigurationException;
+import org.springframework.test.context.event.EventPublishingTestExecutionListener;
import org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener;
import org.springframework.test.context.support.AbstractTestExecutionListener;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
@@ -57,7 +58,7 @@ public class TestExecutionListenersTests {
List> expected = asList(ServletTestExecutionListener.class,
DirtiesContextBeforeModesTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class,
- SqlScriptsTestExecutionListener.class);
+ SqlScriptsTestExecutionListener.class, EventPublishingTestExecutionListener.class);
assertRegisteredListeners(DefaultListenersTestCase.class, expected);
}
@@ -69,7 +70,7 @@ public class TestExecutionListenersTests {
List> expected = asList(QuuxTestExecutionListener.class, ServletTestExecutionListener.class,
DirtiesContextBeforeModesTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class,
- SqlScriptsTestExecutionListener.class);
+ SqlScriptsTestExecutionListener.class, EventPublishingTestExecutionListener.class);
assertRegisteredListeners(MergedDefaultListenersWithCustomListenerPrependedTestCase.class, expected);
}
@@ -81,7 +82,8 @@ public class TestExecutionListenersTests {
List> expected = asList(ServletTestExecutionListener.class,
DirtiesContextBeforeModesTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class,
- SqlScriptsTestExecutionListener.class, BazTestExecutionListener.class);
+ SqlScriptsTestExecutionListener.class, EventPublishingTestExecutionListener.class,
+ BazTestExecutionListener.class);
assertRegisteredListeners(MergedDefaultListenersWithCustomListenerAppendedTestCase.class, expected);
}
@@ -93,7 +95,8 @@ public class TestExecutionListenersTests {
List> expected = asList(ServletTestExecutionListener.class,
DirtiesContextBeforeModesTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
BarTestExecutionListener.class, DirtiesContextTestExecutionListener.class,
- TransactionalTestExecutionListener.class, SqlScriptsTestExecutionListener.class);
+ TransactionalTestExecutionListener.class, SqlScriptsTestExecutionListener.class,
+ EventPublishingTestExecutionListener.class);
assertRegisteredListeners(MergedDefaultListenersWithCustomListenerInsertedTestCase.class, expected);
}
diff --git a/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTests.java b/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTests.java
index 77a8ac9265a..f22673c3bea 100644
--- a/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -30,7 +29,11 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
+import org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener;
+import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import static org.junit.Assert.*;
import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
@@ -44,7 +47,6 @@ import static org.springframework.test.context.junit4.JUnitTestingUtils.*;
* @author Sam Brannen
* @since 3.0
*/
-@RunWith(JUnit4.class)
public class ClassLevelDirtiesContextTests {
private static final AtomicInteger cacheHits = new AtomicInteger(0);
@@ -146,6 +148,14 @@ public class ClassLevelDirtiesContextTests {
@RunWith(SpringRunner.class)
@ContextConfiguration
+ // Ensure that we do not include the EventPublishingTestExecutionListener
+ // since it will access the ApplicationContext for each method in the
+ // TestExecutionListener API, thus distorting our cache hit/miss results.
+ @TestExecutionListeners({
+ DirtiesContextBeforeModesTestExecutionListener.class,
+ DependencyInjectionTestExecutionListener.class,
+ DirtiesContextTestExecutionListener.class
+ })
static abstract class BaseTestCase {
@Configuration
diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/DirtiesContextInterfaceTests.java b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/DirtiesContextInterfaceTests.java
index 85f966da9d8..b22e7c350c2 100644
--- a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/DirtiesContextInterfaceTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/DirtiesContextInterfaceTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,12 +22,15 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
+import org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener;
+import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import static org.junit.Assert.*;
import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
@@ -37,7 +40,6 @@ import static org.springframework.test.context.junit4.JUnitTestingUtils.*;
* @author Sam Brannen
* @since 4.3
*/
-@RunWith(JUnit4.class)
public class DirtiesContextInterfaceTests {
private static final AtomicInteger cacheHits = new AtomicInteger(0);
@@ -72,6 +74,14 @@ public class DirtiesContextInterfaceTests {
@RunWith(SpringRunner.class)
+ // Ensure that we do not include the EventPublishingTestExecutionListener
+ // since it will access the ApplicationContext for each method in the
+ // TestExecutionListener API, thus distorting our cache hit/miss results.
+ @TestExecutionListeners({
+ DirtiesContextBeforeModesTestExecutionListener.class,
+ DependencyInjectionTestExecutionListener.class,
+ DirtiesContextTestExecutionListener.class
+ })
public static class ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
implements DirtiesContextTestInterface {
diff --git a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java
index 0b49bfbbac4..687e99be51d 100644
--- a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java
@@ -41,7 +41,6 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.TestContextManager;
import org.springframework.test.context.TestExecutionListener;
-import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.event.annotation.AfterTestClass;
import org.springframework.test.context.event.annotation.AfterTestExecution;
import org.springframework.test.context.event.annotation.AfterTestMethod;
@@ -193,7 +192,6 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = TestEventListenerConfiguration.class)
- @TestExecutionListeners(EventPublishingTestExecutionListener.class)
public static class ExampleTestCase {
@Traceable
diff --git a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerTests.java b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerTests.java
index ff1593fa918..2ab00c4dce4 100644
--- a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerTests.java
@@ -16,7 +16,12 @@
package org.springframework.test.context.event;
+import java.util.function.Consumer;
+
+import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TestName;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
@@ -26,16 +31,20 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.test.context.TestContext;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
-import static org.junit.Assert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.only;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
/**
* Unit tests for {@link EventPublishingTestExecutionListener}.
*
* @author Frank Scheffler
+ * @author Sam Brannen
* @since 5.2
*/
@RunWith(MockitoJUnitRunner.class)
@@ -49,53 +58,97 @@ public class EventPublishingTestExecutionListenerTests {
@Captor
private ArgumentCaptor testExecutionEvent;
+ @Rule
+ public final TestName testName = new TestName();
+
+
+ @Before
+ public void configureMock() {
+ if (testName.getMethodName().startsWith("publish")) {
+ when(testContext.hasApplicationContext()).thenReturn(true);
+ }
+ }
@Test
public void publishBeforeTestClassEvent() {
- listener.beforeTestClass(testContext);
- assertEvent(BeforeTestClassEvent.class);
+ assertEvent(BeforeTestClassEvent.class, listener::beforeTestClass);
}
@Test
public void publishPrepareTestInstanceEvent() {
- listener.prepareTestInstance(testContext);
- assertEvent(PrepareTestInstanceEvent.class);
+ assertEvent(PrepareTestInstanceEvent.class, listener::prepareTestInstance);
}
@Test
public void publishBeforeTestMethodEvent() {
- listener.beforeTestMethod(testContext);
- assertEvent(BeforeTestMethodEvent.class);
+ assertEvent(BeforeTestMethodEvent.class, listener::beforeTestMethod);
}
@Test
public void publishBeforeTestExecutionEvent() {
- listener.beforeTestExecution(testContext);
- assertEvent(BeforeTestExecutionEvent.class);
+ assertEvent(BeforeTestExecutionEvent.class, listener::beforeTestExecution);
}
@Test
public void publishAfterTestExecutionEvent() {
- listener.afterTestExecution(testContext);
- assertEvent(AfterTestExecutionEvent.class);
+ assertEvent(AfterTestExecutionEvent.class, listener::afterTestExecution);
}
@Test
public void publishAfterTestMethodEvent() {
- listener.afterTestMethod(testContext);
- assertEvent(AfterTestMethodEvent.class);
+ assertEvent(AfterTestMethodEvent.class, listener::afterTestMethod);
}
@Test
public void publishAfterTestClassEvent() {
- listener.afterTestClass(testContext);
- assertEvent(AfterTestClassEvent.class);
+ assertEvent(AfterTestClassEvent.class, listener::afterTestClass);
}
- private void assertEvent(Class extends TestContextEvent> eventClass) {
+ private void assertEvent(Class extends TestContextEvent> eventClass, Consumer callback) {
+ callback.accept(testContext);
verify(testContext.getApplicationContext(), only()).publishEvent(testExecutionEvent.capture());
assertThat(testExecutionEvent.getValue(), instanceOf(eventClass));
assertThat(testExecutionEvent.getValue().getSource(), equalTo(testContext));
}
+ @Test
+ public void doesNotPublishBeforeTestClassEventIfApplicationContextHasNotBeenLoaded() {
+ assertNoEvent(listener::beforeTestClass);
+ }
+
+ @Test
+ public void doesNotPublishPrepareTestInstanceEventIfApplicationContextHasNotBeenLoaded() {
+ assertNoEvent(listener::prepareTestInstance);
+ }
+
+ @Test
+ public void doesNotPublishBeforeTestMethodEventIfApplicationContextHasNotBeenLoaded() {
+ assertNoEvent(listener::beforeTestMethod);
+ }
+
+ @Test
+ public void doesNotPublishBeforeTestExecutionEventIfApplicationContextHasNotBeenLoaded() {
+ assertNoEvent(listener::beforeTestExecution);
+ }
+
+ @Test
+ public void doesNotPublishAfterTestExecutionEventIfApplicationContextHasNotBeenLoaded() {
+ assertNoEvent(listener::afterTestExecution);
+ }
+
+ @Test
+ public void doesNotPublishAfterTestMethodEventIfApplicationContextHasNotBeenLoaded() {
+ assertNoEvent(listener::afterTestMethod);
+ }
+
+ @Test
+ public void doesNotPublishAfterTestClassEventIfApplicationContextHasNotBeenLoaded() {
+ assertNoEvent(listener::afterTestClass);
+ }
+
+ private void assertNoEvent(Consumer callback) {
+ callback.accept(testContext);
+ verify(testContext.getApplicationContext(), never()).publishEvent(any());
+ }
+
}
diff --git a/src/docs/asciidoc/testing.adoc b/src/docs/asciidoc/testing.adoc
index bf4c220fc73..eed948f5573 100644
--- a/src/docs/asciidoc/testing.adoc
+++ b/src/docs/asciidoc/testing.adoc
@@ -1659,11 +1659,8 @@ subclasses instead.
==== `TestExecutionListener` Configuration
Spring provides the following `TestExecutionListener` implementations that are registered
-exactly in the following order. Except for the `EventPublishingTestExecutionListener`,
-each of these listeners is registered by default.
+by default, exactly in the following order:
-* `EventPublishingTestExecutionListener`: Publishes test execution events to the test's
- `ApplicationContext` (see <>).
* `ServletTestExecutionListener`: Configures Servlet API mocks for a
`WebApplicationContext`.
* `DirtiesContextBeforeModesTestExecutionListener`: Handles the `@DirtiesContext`
@@ -1676,6 +1673,8 @@ each of these listeners is registered by default.
default rollback semantics.
* `SqlScriptsTestExecutionListener`: Runs SQL scripts configured by using the `@Sql`
annotation.
+* `EventPublishingTestExecutionListener`: Publishes test execution events to the test's
+ `ApplicationContext` (see <>).
[[testcontext-tel-config-registering-tels]]
===== Registering `TestExecutionListener` Implementations
@@ -1695,7 +1694,7 @@ become cumbersome if a custom listener needs to be used across a test suite. Sin
Framework 4.1, this issue is addressed through support for automatic discovery of default
`TestExecutionListener` implementations through the `SpringFactoriesLoader` mechanism.
-Specifically, the `spring-test` module declares all core default TestExecutionListener`
+Specifically, the `spring-test` module declares all core default `TestExecutionListener`
implementations under the `org.springframework.test.context.TestExecutionListener` key in
its `META-INF/spring.factories` properties file. Third-party frameworks and developers
can contribute their own `TestExecutionListener` implementations to the list of default
@@ -1786,11 +1785,10 @@ be replaced with the following:
==== Test Execution Events
The `EventPublishingTestExecutionListener` introduced in Spring Framework 5.2 offers an
-alternative approach to implementing a custom `TestExecutionListener`. If the
-`EventPublishingTestExecutionListener` is <>, components in the `ApplicationContext` can listen to the following events
-published by the `EventPublishingTestExecutionListener`. Each of these events corresponds
-to a method in the `TestExecutionListener` API.
+alternative approach to implementing a custom `TestExecutionListener`. Components in the
+test's `ApplicationContext` can listen to the following events published by the
+`EventPublishingTestExecutionListener`, each of which corresponds to a method in the
+`TestExecutionListener` API.
* `BeforeTestClassEvent`
* `PrepareTestInstanceEvent`
@@ -1800,6 +1798,8 @@ to a method in the `TestExecutionListener` API.
* `AfterTestMethodEvent`
* `AfterTestClassEvent`
+NOTE: These events are only published if the `ApplicationContext` has already been loaded.
+
These events may be consumed for various reasons, such as resetting mock beans or tracing
test execution. One advantage of consuming test execution events rather than implementing
a custom `TestExecutionListener` is that test execution events may be consumed by any