spring-framework
spring-framework copied to clipboard
Access recorded ApplicationEvents across all threads in the TestContext framework
Affects: 5.3.22
Feature Request:
When using @RecordApplicationEvents, currently the ApplicationEventsHolder uses a ThreadLocal to save published events. Can this be extended to also retrieve events across all threads?
Use cases:
- Assert on async events
- Whether or not the event itself was async, when using an async test library like Awaitility in this way:
await().untilAsserted(() -> assertThat(applicationEvents.stream())..... );The assertion runs in a different thread (so that Awaitility can time and interrupt if necessary), so no events are found whatsoever.