Document the effect of @DirtiesContext on test execution events

See gh-27757
This commit is contained in:
Sam Brannen
2022-03-12 16:02:20 +01:00
parent 8a510db00d
commit d9c22e657f
3 changed files with 245 additions and 1 deletions

View File

@@ -2725,6 +2725,10 @@ If you wish to ensure that a `BeforeTestClassEvent` is always published for ever
class, you need to register a `TestExecutionListener` that loads the `ApplicationContext`
in the `beforeTestClass` callback, and that `TestExecutionListener` must be registered
_before_ the `EventPublishingTestExecutionListener`.
Similarly, if `@DirtiesContext` is used to remove the `ApplicationContext` from the
context cache after the last test method in a given test class, the `AfterTestClassEvent`
will not be published for that test class.
====
In order to listen to test execution events, a Spring bean may choose to implement the