For my Spring-Boot app I provide a RestTemplate though a @Configuration file so I can add sensible defaults(ex Timeouts). For my integration tests I would like to mock the R
Getting a little deeper into it, see my second answer.
I solved the Problem using
@SpringBootTest(classes = {AppConfiguration.class, AppTestConfiguration.class})
instead of
@Import({ AppConfiguration.class, AppTestConfiguration.class });
In my case the Test is not in the same package as the App. So I need to specify the AppConfiguration.class (or the App.class) explicit. If you use the same package in the test, than I guess you could just write
@SpringBootTest(classes = AppTestConfiguration.class)
instead of (not working)
@Import(AppTestConfiguration.class );
It is pretty wired to see that this is so different. Maybe some one can explain this. I could not find any good answers until now. You might think, @Import(...)
is not picked up if @SpringBootTests
is present, but in the log the overriding bean shows up. But just the wrong way around.
By the way, using @TestConfiguration
instead @Configuration
also makes no difference.