diff --git a/spring-test/src/main/java/org/springframework/test/context/support/DefaultTestContext.java b/spring-test/src/main/java/org/springframework/test/context/support/DefaultTestContext.java index 5066dce3ef..72da428519 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/DefaultTestContext.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/DefaultTestContext.java @@ -103,8 +103,13 @@ public class DefaultTestContext implements TestContext { if (context instanceof ConfigurableApplicationContext) { @SuppressWarnings("resource") ConfigurableApplicationContext cac = (ConfigurableApplicationContext) context; - Assert.state(cac.isActive(), () -> "The ApplicationContext loaded for [" + mergedContextConfiguration - + "] is not active. Ensure that the context has not been closed programmatically."); + Assert.state(cac.isActive(), () -> + "The ApplicationContext loaded for [" + mergedContextConfiguration + + "] is not active. This may be due to one of the following reasons: " + + "1) the context was closed programmatically by user code; " + + "2) the context was closed during parallel test execution either " + + "according to @DirtiesContext semantics or due to automatic eviction " + + "from the ContextCache due to a maximum cache size policy."); } return context; }