This commit modifies the way the @RecordApplicationEvents
annotation
works in tests, allowing for capture of events from threads other than
the main test thread (async events) and for the assertion of captured
event from a separate thread (e.g. when using Awaitility
).
This is done by switching the ApplicationEventsHolder
to use an
InheritedThreadLocal
.
There is a mutual exclusion between support of asynchronous events vs
support of JUnit5 parallel tests with the @TestInstance(PER_CLASS)
mode. As a result, we favor the former and now SpringExtension
will
invalidate a test class that is annotated (or meta-annotated, or
enclosed-annotated) with @RecordApplicationEvents
AND
@TestInstance(PER_CLASS)
AND @Execution(CONCURRENT)
.
Closes gh-29827
Comment From: simonbasle
cc @odrotbohm
draft as this should probably be slated for 6.1.0
Comment From: simonbasle
Now that main
contains work for 6.1.0, this is ready to be reviewed / merged