Skip to content
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

Introduce publishEvent() convenience method in TestContext #22765

Closed
1 task done
sbrannen opened this issue Apr 8, 2019 · 0 comments
Closed
1 task done

Introduce publishEvent() convenience method in TestContext #22765

sbrannen opened this issue Apr 8, 2019 · 0 comments
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Apr 8, 2019

Status Quo

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(new MyEvent());
}

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.
@sbrannen sbrannen added in: test Issues in the test module type: enhancement A general enhancement labels Apr 8, 2019
@sbrannen sbrannen added this to the 5.2 M1 milestone Apr 8, 2019
@sbrannen sbrannen self-assigned this Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant