Question 1
What does annotating a test with @DirtiesContext cause?
A. The test fails immediately
The annotation is not a failure signal; it says nothing about the test's outcome and does not cause it to fail.
B. It has no effect on context caching
The whole point of the annotation is to affect caching — it evicts the cached context, so claiming it has no effect on caching is wrong.
C. Only the database is reset, the context stays cached
This confuses a data reset with a context reset; the annotation targets the whole ApplicationContext, not just the database, and the context is discarded rather than kept cached.
D. The cached ApplicationContext is closed and rebuilt, so it is not reused by later testsCorrect answer
Correct: the annotation signals that the test mutated the context, so the framework closes and rebuilds it instead of reusing the cached instance (Spring Framework 5.3 Reference — @DirtiesContext).
Explanation
@DirtiesContext signals that a test has mutated the shared ApplicationContext, so the TestContext framework evicts and rebuilds it rather than serving the cached instance to later tests. This prevents cross-test contamination by ensuring subsequent tests start from a fresh context, and it operates on the entire context, not merely on database state.