I’m writing some Spring boot tests. When using @SpringBootTest
, it works fine, I got all auto configurations classes from spring jars. But I don’t want to load the whole application context from @SpringBootApplication
For example I’m testing spring batch layer. I would like to benefit from all spring batch autoconfiguration.
Here’s my test class :
@ContextConfiguration(classes = BankBatchApplicationTests.TestConfig.class)
@SpringBatchTest
@EnableAutoConfiguration
class BankBatchApplicationTests {
@ComponentScan("com.example")
static class TestConfig {
}
But it seems my test class isn’t picking up auto configuration from spring-batch. Obviously when I use @SpringBootTest
it works fine
Another solution would be to use @SpringBootTest, picking up my main @SpringBootApplication Application
class. But I don’t want to include other configurations classes scanned like KafkaConfiguration
etc…
2