I am trying to write Integration test for spring batch aplication , in my project there are approx 10+jobs I want to run only a single job but unable to achieve any Suggestion.
@SpringBatchTest
@RunWith(SpringRunner.class)
@ContextConfiguration(classes= MyApp.class)
@SpringBootTest
@Slf4j
public class JobATest {
JobLauncherTestUtils jobLauncherTestUtils = new JobLauncherTestUtils();
@Autowired
@Qualifier(JOB_A)
Job joba;
@Before
public void setUp() throws Exception {
log.debug("CAME HERE setUp {} ",joba.getName());
jobLauncherTestUtils.setJob(joba);
}
@After
public void tearDown() throws Exception {
}
@Test
public void processAJob() throws Exception {
jobLauncherTestUtils.launchJob();
}
}
ERROR
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'jobLauncherTestUtils': Unsatisfied dependency expressed
through method 'setJob' parameter 0; nested exception is
org.springframework.beans.factory.NoUniqueBeanDefinitionException:
No qualifying bean of type 'org.springframework.batch.core.Job' available:
expected single matching bean but found 2: **joba,jobb**