You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It has always been possible for a TestExecutionListener to publish an ApplicationEvent to the current test's ApplicationContext via testContext.getApplicationContext().publishEvent(new MyEvent()); however, that resulted in undesirable loading of the ApplicationContext in some cases.
Typically people only want to publish events if the ApplicationContext is currently available.
The testContext.hasApplicationContext() support introduced in gh-22756 makes it possible to only publish events if the ApplicationContext is currently available as follows.
if (testContext.hasApplicationContext()) {
testContext.getApplicationContext().publishEvent(newMyEvent());
}
This issue aims to introduce a convenience method in the TestContext API that performs the above with lazy creation of the actual ApplicationEvent.
Deliverables
Introduce publishEvent() convenience method in TestContext.
The text was updated successfully, but these errors were encountered:
Status Quo
It has always been possible for a
TestExecutionListener
to publish anApplicationEvent
to the current test'sApplicationContext
viatestContext.getApplicationContext().publishEvent(new MyEvent())
; however, that resulted in undesirable loading of theApplicationContext
in some cases.Typically people only want to publish events if the
ApplicationContext
is currently available.The
testContext.hasApplicationContext()
support introduced in gh-22756 makes it possible to only publish events if theApplicationContext
is currently available as follows.This issue aims to introduce a convenience method in the
TestContext
API that performs the above with lazy creation of the actualApplicationEvent
.Deliverables
publishEvent()
convenience method inTestContext
.The text was updated successfully, but these errors were encountered: