diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListener.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListener.java index 5b3fcbd0fc..90d186d325 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListener.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListener.java @@ -44,11 +44,15 @@ public class SpringBootDependencyInjectionTestExecutionListener super.prepareTestInstance(testContext); } catch (Exception ex) { - ApplicationContext context = testContext.getApplicationContext(); - if (context instanceof ConfigurableApplicationContext) { - ConditionEvaluationReport report = ConditionEvaluationReport - .get(((ConfigurableApplicationContext) context).getBeanFactory()); - System.err.println(new ConditionEvaluationReportMessage(report)); + try { + ApplicationContext context = testContext.getApplicationContext(); + if (context instanceof ConfigurableApplicationContext) { + ConditionEvaluationReport report = ConditionEvaluationReport + .get(((ConfigurableApplicationContext) context).getBeanFactory()); + System.err.println(new ConditionEvaluationReportMessage(report)); + } + } + catch (Exception ignore) { } throw ex; }