When using @SpringBatchTest, it is expected that the test context contains a bean of type DataSource. This is mentioned in the Javadoc of the annotation, here is an excerpt:
It should be noted that JobLauncherTestUtils requires a Job bean
and that JobRepositoryTestUtils requires a DataSource bean. Since
this annotation registers a JobLauncherTestUtils and a JobRepositoryTestUtils
in the test context, it is expected that the test context contains
a single autowire candidate for a Job and a DataSource
If all you need is a JobLauncherTestUtils but not other test utilities, you can define a JobLauncherTestUtils bean manually in your test class, something like:
@Bean
public JobLauncherTestUtils testUtils() {
JobLauncherTestUtils jobLauncherTestUtils = new JobLauncherTestUtils();
jobLauncherTestUtils.setJob(jobUnderTest);
return jobLauncherTestUtils;
}