Assume two @Component's are defined, like this:
@Component
public class UnderTesting {
}
@Component
public class Irrelevant {
}
The unit test is like this:
@SpringBootTest
public Test_UnderTesting {
@Autowired
private UnderTesting foo;
@Test
public void testSomething() {
}
}
When running this test case with mvn test, spring will construct component Irrelevant even though it's completely irrelevant.
In my case the component Irrelevant cannot be constructed due to unavailability of complex dependencies in the unit test environment.
My question is: how to avoid constructing Irrelevant (and other unnecessary components) during unit test ?
I'm kind new to spring boot, so I may have been heading a wrong direction, any suggestions are welcome.