Overview
While working on the tests for #36782, I noticed that MicrometerObservationRegistryTestExecutionListener eagerly loads an ApplicationContext like MockitoResetTestExecutionListener previously did.
The Javadoc states that it:
updates the ObservationThreadLocalAccessor with the ObservationRegistry obtained from the test's ApplicationContext, if present.
However, the last part is misleading. While it's true that it only does that if the ObservationRegistry is present in the context, it always loads the context to check if the ObservationRegistry is present.
Whereas, it should not do anything if the current test does not have an active ApplicationContext.
Related Issues
Overview
While working on the tests for #36782, I noticed that
MicrometerObservationRegistryTestExecutionListenereagerly loads anApplicationContextlikeMockitoResetTestExecutionListenerpreviously did.The Javadoc states that it:
However, the last part is misleading. While it's true that it only does that if the
ObservationRegistryis present in the context, it always loads the context to check if theObservationRegistryis present.Whereas, it should not do anything if the current test does not have an active
ApplicationContext.Related Issues
ApplicationContext#36782