spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Access recorded ApplicationEvents across all threads in the TestContext framework

Open jhyot opened this issue 3 years ago • 0 comments

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.

jhyot avatar Aug 03 '22 09:08 jhyot