Simplify printing ConditionEvaluationReport when using context runner

Closes gh-13119
This commit is contained in:
Madhura Bhave
2018-09-14 12:55:43 -07:00
parent fc60d9f6d4
commit d7d5cbf959
7 changed files with 95 additions and 18 deletions

View File

@@ -7659,6 +7659,23 @@ example:
include::{test-examples}/autoconfigure/UserServiceAutoConfigurationTests.java[tag=test-env]
----
The runner can also be used to display the `ConditionEvaluationReport`. The report can be printed
at `INFO` or `DEBUG` level. The following example shows how to use the `ConditionEvaluationReportLoggingListener`
to print the report in auto-configuration tests.
[source,java,indent=0]
----
@Test
public void autoConfigTest {
ConditionEvaluationReportLoggingListener initializer = new ConditionEvaluationReportLoggingListener(
LogLevel.INFO);
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withInitializer(initializer).run((context -> {
// Do something...
}));
}
----
==== Simulating a Web Context