-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@RecordApplicationEvents
doesn't work on threads spawned before the test execution
#31079
Comments
I don't think there is a perfect solution for your use case beyond what was introduced in #30020. Perhaps the scope of As a possible workaround however, maybe you could have your |
Unfortunately my real use case was a I finally moved on from |
yeah that makes sense that the real setup is a little bit more complex. the test recording of events is aiming at capturing events specific to a given test, first and foremost, in order to let users assert a shorter scope of test-fired events exhaustively without being overwhelmed by unrelated events. glad you found a creative workaround solution for your test. I've added a short note in the javadoc of |
I just ran into the same issue. Now rolling my own version of this, which I think is a pity. |
The issue with
ApplicationEventsHolder
and itsInheritableThreadLocal
solution implemented in #30020 is that it only works if the thread is spawned in the test method like in the unit testJUnit4ApplicationEventsAsyncIntegrationTests
but if the thread is spawned beforeregisterApplicationEvents
is called on the main/parent thread (for instance during application context creation), then every application event emitted during the test on this spawned thread will be ignored.Here's a slightly modified version of
JUnit4ApplicationEventsAsyncIntegrationTests
that reproduce the issue:The text was updated successfully, but these errors were encountered: