注释步骤配置,如何检验
问题描述:
我用春天批次注解而已,我要测试的配置,像这样一个步骤:注释步骤配置,如何检验
@Bean("findMe")
@Qualifier("findMe")
public Step findMe() {
return stepBuilderFactory.get("findMe"). ... some step configuration
}
测试:
@Test
public shouldRunTheJob() {
JobLauncherTestUtils.launchJob("findMe");
}
我没有能力解决这个问题,除此之外,我能够测试其他所有层面,我怎样才能解决像这样注释的工作?
答
从我的理解你的问题,你想测试一个步骤,而不是一份工作。
尝试使用以下样本测试类作为步骤测试。
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = YourClassToTest.class)
public class StepTest {
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;
@Test
public void testStep() throws Exception {
JobExecution jobExecution = jobLauncherTestUtils.launchStep("findMe");
// your test case, e.g. assert something on the jobExecution
}
}
欲了解更多信息,请参阅春季批处理文档here。