diff --git a/spring-framework-reference/src/testing.xml b/spring-framework-reference/src/testing.xml index f9be02e082f5abf1bd7ea153f99e335ebd4a1f8d..820737996b359156543e3c22df61267a8cf372ad 100644 --- a/spring-framework-reference/src/testing.xml +++ b/spring-framework-reference/src/testing.xml @@ -409,7 +409,7 @@ Spring-specific annotations that you can use in your unit and integration tests in conjunction with the TestContext framework. Refer to the respective JavaDoc for further information, - including default attribute values, etc. + including default attribute values, attribute aliases, etc. @@ -419,10 +419,10 @@ Defines class-level metadata which is used to determine how to load and configure an ApplicationContext. Specifically, - @ContextConfiguration defines the application context resource - locations to load as well as the - ContextLoader strategy to use for - loading the context. + @ContextConfiguration defines the + application context resource locations to + load as well as the ContextLoader + strategy to use for loading the context. @ContextConfiguration(locations={"example/test-context.xml"}, loader=CustomContextLoader.class) public class CustomConfiguredApplicationContextTests { @@ -442,16 +442,37 @@ public class CustomConfiguredApplicationContextTests { role="bold">@DirtiesContext The presence of this annotation on a test method indicates - that the underlying Spring container is 'dirtied' during the - execution of the test method, and thus must be rebuilt after the - test method finishes execution (regardless of whether the test - passed or not). + that the underlying Spring container has been dirtied + during the execution of the test method and thus must be closed after the + test method finishes execution (regardless of whether the annotated test + passed or not). Similarly, if a test class is annotated with + @DirtiesContext, the underlying + Spring container will be marked as dirty after all tests in the + class have completed execution. + + @DirtiesContext +public class ContextDirtyingTests { + // some tests that result in the Spring container being dirtied +} @DirtiesContext @Test public void testProcessWhichDirtiesAppCtx() { // some logic that results in the Spring container being dirtied } + + Whenever an application context is marked as + dirty, it will be removed from the testing + framework's cache and closed; thus the underlying Spring container will be + rebuilt for any subsequent test which requires a context with the + same set of resource locations. + + + Limitations of <interfacename>@DirtiesContext</interfacename> with JUnit 3.8 + In a JUnit 3.8 environment @DirtiesContext + is only supported on methods and thus not at the class level. + +