Prior to this commit, finding out how many application contexts had
been loaded within a test suite required the use of reflection and a
bit of hacking.
This commit addresses this issue by logging ContextCache statistics
whenever an application context is loaded by the Spring TestContext
Framework (TCF).
The log output can be enabled by setting the
"org.springframework.test.context.cache" logging category to DEBUG.
Issue: SPR-12409
@ -20851,6 +20851,12 @@ framework will not be able to cache application contexts between test classes an
@@ -20851,6 +20851,12 @@ framework will not be able to cache application contexts between test classes an
build process will run significantly slower as a result.
====
Since having a large number of application contexts loaded within a given test suite can
cause the suite to take an unnecessarily long time to execute, it is often beneficial to
know exactly how many contexts have been loaded and cached. To view the statistics for
the underlying context cache, simply set the log level for the
`org.springframework.test.context.cache` logging category to `DEBUG`.
In the unlikely case that a test corrupts the application context and requires reloading
-- for example, by modifying a bean definition or the state of an application object --
you can annotate your test class or test method with `@DirtiesContext` (see the
@ -20860,6 +20866,7 @@ context before executing the next test. Note that support for the `@DirtiesConte
@@ -20860,6 +20866,7 @@ context before executing the next test. Note that support for the `@DirtiesConte
annotation is provided by the `DirtiesContextTestExecutionListener` which is enabled by