Using Spring Boot 1.5.16 in WebMvcTest I'm trying to load test.properties applying @TestPropertySource annotation in order to override some properties in test class. This works just fine if I put it on test class:
@RunWith(SpringRunner.class) @WebMvcTest @TestPropertySource("classpath:test.properties") public class ControllerTest { ... } But properties not loaded if I move it to imported configuration:
@RunWith(SpringRunner.class) @WebMvcTest @Import(ControllersConfiguration.class) public class ControllerTest { ... } and ControllersConfiguration class is:
@TestConfiguration @TestPropertySource("classpath:test.properties") public class ControllersConfiguration { ... } Can you explain that behavior?
P.S. @PropertySource annotation is working in imported configuration, but with lowest precedence than application.properties
UPD: To be clear - try to make all test pass here: https://github.com/Javasick/WeirdTestPropertySource
inheritLocationsfor@TestPropertySourceasfalse?