I am testing a Spring Boot application. I have several test classes, each of which needs a different set of mocked or otherwise customized beans.
Here is a sketch of
I would do a couple of things:
@ComponentScaning them.Component1TestWithFakeCommunication, change @SpringApplicationConfiguration(classes = MyApplication.class) to @SpringApplicationConfiguration(classes = {MyApplication.class, Component1TestWithFakeCommunication.ContextConfiguration.class})That should give Spring sufficient information to mock up the test beans, but it should prevent the runtime ApplicationContext from noticing your test beans as well.