Skip to content

Commit

Permalink
Register EventPublishingTestExecutionListener by default
Browse files Browse the repository at this point in the history
Closes gh-18490
  • Loading branch information
sbrannen committed Apr 3, 2019
1 parent d617351 commit 13543f5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@
* support. For further details, consult the class-level Javadoc for
* {@link org.springframework.context.event.EventListener @EventListener}.
*
* <h3>Listener Registration</h3>
* <p>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
* @since 5.2
Expand Down
1 change: 1 addition & 0 deletions spring-test/src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Default TestExecutionListeners for the Spring TestContext Framework
#
org.springframework.test.context.TestExecutionListener = \
org.springframework.test.context.event.EventPublishingTestExecutionListener,\
org.springframework.test.context.web.ServletTestExecutionListener,\
org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener,\
org.springframework.test.context.support.DependencyInjectionTestExecutionListener,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
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;
Expand Down Expand Up @@ -193,7 +192,6 @@ public void afterTestClassAnnotation() throws Exception {

@RunWith(SpringRunner.class)
@ContextConfiguration(classes = TestEventListenerConfiguration.class)
@TestExecutionListeners(EventPublishingTestExecutionListener.class)
public static class ExampleTestCase {

@Traceable
Expand Down
12 changes: 5 additions & 7 deletions src/docs/asciidoc/testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1659,8 +1659,7 @@ 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 <<testcontext-test-execution-events>>).
Expand Down Expand Up @@ -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 <<testcontext-tel-config-registering-tels,
registered>>, 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 `ApplicationContext` can listen to the following events published by the
`EventPublishingTestExecutionListener`, each of which corresponds to a method in the
`TestExecutionListener` API.

* `BeforeTestClassEvent`
* `PrepareTestInstanceEvent`
Expand Down

0 comments on commit 13543f5

Please sign in to comment.