File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
framework-docs/modules/ROOT/pages/testing/annotations/integration-spring
spring-test/src/main/java/org/springframework/test/annotation Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ metadata.
12
12
You can use `@DirtiesContext` as both a class-level and a method-level annotation within
13
13
the same class or class hierarchy. In such scenarios, the `ApplicationContext` is marked
14
14
as dirty before or after any such annotated method as well as before or after the current
15
- test class, depending on the configured `methodMode` and `classMode`.
15
+ test class, depending on the configured `methodMode` and `classMode`. When
16
+ `@DirtiesContext` is declared at both the class level and the method level, the
17
+ configured modes from both annotations will be honored. For example, if the class mode is
18
+ set to `BEFORE_EACH_TEST_METHOD` and the method mode is set to `AFTER_METHOD`, the
19
+ context will be marked as dirty both before and after the given test method.
16
20
17
21
The following examples explain when the context would be dirtied for various
18
22
configuration scenarios:
Original file line number Diff line number Diff line change 39
39
* {@code ApplicationContext} will be marked as <em>dirty</em> before or
40
40
* after any such annotated method as well as before or after the current test
41
41
* class, depending on the configured {@link #methodMode} and {@link #classMode}.
42
+ * When {@code @DirtiesContext} is declared at both the class level and the
43
+ * method level, the configured test phases from both annotations will be honored.
44
+ * For example, if the class mode is set to {@link ClassMode#BEFORE_EACH_TEST_METHOD
45
+ * BEFORE_EACH_TEST_METHOD} and the method mode is set to
46
+ * {@link MethodMode#AFTER_METHOD AFTER_METHOD}, the context will be marked as
47
+ * dirty both before and after the given test method.
42
48
*
43
49
* <h3>Supported Test Phases</h3>
44
50
* <ul>
You can’t perform that action at this time.
0 commit comments