Status Quo
A custom TestExecutionListener can gain access to the test's ApplicationContext via TestContext#getApplicationContext(); however, there are times when a custom TestExecutionListener would like to know if the ApplicationContext is already available (i.e., has already been successfully loaded and cached) before proceeding with a particular action.
Invoking TestContext#getApplicationContext() just to see if the ApplicationContext can be loaded is not a good option, since that will eagerly load the context, potentially resulting in negative side effects.
Proposal
Introduce support in the TestContext framework that allows a TestExecutionListener to query whether the test's ApplicationContext has already been loaded.
Related Issues
Deliverables
Status Quo
A custom
TestExecutionListenercan gain access to the test'sApplicationContextviaTestContext#getApplicationContext(); however, there are times when a customTestExecutionListenerwould like to know if theApplicationContextis already available (i.e., has already been successfully loaded and cached) before proceeding with a particular action.Invoking
TestContext#getApplicationContext()just to see if theApplicationContextcan be loaded is not a good option, since that will eagerly load the context, potentially resulting in negative side effects.Proposal
Introduce support in the TestContext framework that allows a
TestExecutionListenerto query whether the test'sApplicationContexthas already been loaded.Related Issues
Deliverables
boolean hasApplicationContext()in theTestContextAPI.boolean isContextLoaded(MergedContextConfiguration)in theCacheAwareContextLoaderDelegateAPI.