To test springboot auto-wiring, use:
@SpringBootTest(classes = {A.class, B.class, C.class})
@ActiveProfiles("test")
class ATest {
@Autowired
private A subject;
@MockBean
private B b; // want to use a mock or spy
Use @SpringBootTest to start Spring
without (classes = ) Spring would do normal start, and result in a lot of unrelated instances initiating, therefore slower and may not possible
Use @ActiveProfiles to choose a profile, therefore enables different configurations (such as "application-test.properties")