Skip to content

Latest commit

 

History

History
46 lines (39 loc) · 1.83 KB

annotation-testexecutionlisteners.adoc

File metadata and controls

46 lines (39 loc) · 1.83 KB

@TestExecutionListeners

@TestExecutionListeners is used to register listeners for a particular test class, its subclasses, and its nested classes. If you wish to register a listener globally, you should register it via the automatic discovery mechanism described in TestExecutionListener Configuration.

The following example shows how to register two TestExecutionListener implementations:

Java
@ContextConfiguration
@TestExecutionListeners({CustomTestExecutionListener.class, AnotherTestExecutionListener.class}) // (1)
class CustomTestExecutionListenerTests {
	// class body...
}
  1. Register two TestExecutionListener implementations.

Kotlin
@ContextConfiguration
@TestExecutionListeners(CustomTestExecutionListener::class, AnotherTestExecutionListener::class) // (1)
class CustomTestExecutionListenerTests {
	// class body...
}
  1. Register two TestExecutionListener implementations.

By default, @TestExecutionListeners provides support for inheriting listeners from superclasses or enclosing classes. See @Nested test class configuration and the {spring-framework-api}/test/context/TestExecutionListeners.html[@TestExecutionListeners javadoc] for an example and further details. If you discover that you need to switch back to using the default TestExecutionListener implementations, see the note in Registering TestExecutionListener Implementations.