Testing auto-configurations with Spring Boot 2.0
Auto-configuration is one of the most powerful features of Spring Boot. Tests for auto-configuration classes usually follow the same pattern. Most tests start up an ApplicationContext
with the auto-configuration class under test and depending on the test, also load additional configuration to simulate user behavior. The recurrence of this pattern can add a lot of repetition in the code base.
Spring Boot 2.0 provides a suite of new test helpers for easily configuring an ApplicationContext
to simulate auto-configuration test scenarios. The following example configures an ApplicationContextRunner
to test the UserServiceAutoConfiguration
…