Java JUnit测试与@SpringApplicationConfiguration一起自动启动作业
我正在为spring引导批处理编写Junit测试。 在我的JUnit中,我想启动以下步骤:Java JUnit测试与@SpringApplicationConfiguration一起自动启动作业,java,testing,junit,spring-boot,spring-batch,Java,Testing,Junit,Spring Boot,Spring Batch,我正在为spring引导批处理编写Junit测试。 在我的JUnit中,我想启动以下步骤: JobExecution jobExecution = jobLauncherTestUtils.launchStep("y"); 我的JUnit课程是一门非常有趣的课程: @SpringApplicationConfiguration(classes = { MyBatchConfiguration.class }) @RunWith(SpringJUnit4ClassRunner.class) 我
JobExecution jobExecution = jobLauncherTestUtils.launchStep("y");
我的JUnit课程是一门非常有趣的课程:
@SpringApplicationConfiguration(classes = { MyBatchConfiguration.class })
@RunWith(SpringJUnit4ClassRunner.class)
我的问题是,即使测试方法中没有任何内容,也会以正常方式启动所有批处理作业。
这是我的BatchConf文件上的注释
@Configuration
@EnableBatchProcessing
@EnableAutoConfiguration
@ConditionalOnClass({ JobLauncher.class })
@ComponentScan({ "toto" })
以及由我的测试自动启动的作业:(
只需使用以下内容创建
src/test/resources/application.properties
文件:
spring.batch.job.enabled=false # Do not execute all Spring Batch jobs in the context on startup.
只需使用以下内容创建
src/test/resources/application.properties
文件:
spring.batch.job.enabled=false # Do not execute all Spring Batch jobs in the context on startup.