I want to write a kind of integration test, but only for a specific class. Which means I want all fields in that class to be automatically wired, but neglect any classes inside the same directory.
Is that possible?
Example:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {TestConfig.class})
public class JunitTest {
@Autowired
private MyService service;
}
//how to only scan that specific class?
@ComponentScan(basePackageClasses = {MyService.class, MyInjectedService.class})
@Configuration
public class TestConfig {
}
@Service
public class MyService {
@Autowired
private MyInjectedService service;
}
Here I want spring to neglect any classes in the same directories as the both basePackageClasses
mentioned.