-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Saurabh Chandra opened SPR-8854 and commented
Status Quo
As of Spring Framework 3.2, the TestExecutionListener
implementations ServletTestExecutionListener
DependencyInjectionTestExecutionListener
, DirtiesContextTestExecutionListener
, and TransactionalTestExecutionListener
are automatically registered by default.
However, if a custom TestExecutionListener
is registered via @TestExecutionListeners
then the defaults will not be registered. In most common testing scenarios, this effectively forces the user to manually declare all default listeners in addition to any custom listeners, for example:
@TestExecutionListeners(
{
MyCustomTestExecutionListener.class,
ServletTestExecutionListener.class,
DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class,
TransactionalTestExecutionListener.class
}
)
The problem with this approach is that it requires that the user know exactly which listeners are registered by default. Moreover, this set can change from release to release -- for example, ServletTestExecutionListener
was added in release 3.2.
Proposal
Provide a mechanism for instructing the TestContext framework to register all default TestExecutionListeners
in addition to an explicitly configured custom TestExecutionListener
.
This could be achieved via a new boolean flag in @TestExecutionListeners
. Alternatively, an enum could be introduced that specifies how defaults should be handled -- for example, prepended to custom listeners, appended to customer listeners, or excluded (i.e., the current behavior).
If this proposal is not implemented, it should at least be clearly documented in both Javadoc and the reference manual that the defaults are not prepended by default when specifying a custom TestExecutionListener
.
Affects: 3.0 GA
Issue Links:
- SEC-2587 Improvements in Spring Test ("is depended on by")
- Document support for merging custom TELs with default TELs in the reference manual [SPR-12083] #16699 Document support for merging custom TELs with default TELs in the reference manual ("is depended on by")
- Introduce mechanism for automatic discovery of default TestExecutionListeners [SPR-11466] #16092 Introduce mechanism for automatic discovery of default TestExecutionListeners
Referenced from: commits 66250b1
2 votes, 2 watchers