vendredi 5 février 2016

JUnit test with @SpringApplicationConfiguration start automatically the Job

I'm writing a Junit test for a spring boot batch. In my JUnit I want to launch a step with this:

JobExecution jobExecution = jobLauncherTestUtils.launchStep("y");

My JUnit class is anotated with theese:

@SpringApplicationConfiguration(classes = { MyBatchConfiguration.class })
@RunWith(SpringJUnit4ClassRunner.class)

My problem is that the test even with nothing inside the test method, launch all my batch job as it was launched in the normal way. Here are the annotation on my BatchConfFile

@Configuration
@EnableBatchProcessing
@EnableAutoConfiguration
@ConditionalOnClass({ JobLauncher.class })
@ComponentScan({ "toto" })

and the Job automatically launched by my test :(

@Bean
public Job MyJob(@Qualifier("x") Step x, 
@Qualifier("y") Step y) {

        return jobs.get("j").incrementer(new DateJobIncrementer()).start(x).next(y).build();
    }

Aucun commentaire:

Enregistrer un commentaire