相关疑难解决方法(0)

在Spring-Batch中测试作业流的最佳方法是什么?

我有一个复杂的批处理应用程序,我想测试我对流程的假设是否正确.

这是我正在使用的简化版本:

<beans>
  <batch:job id="job1">
    <batch:step id="step1" next="step2">
      <batch:tasklet ref="someTask1"/>
    </batch:step>
    <batch:step id="step2.master">
      <batch:partition partitioner="step2Partitioner"
            step="step2" />
      <batch:next on="*" to="step3" />
      <batch:next on="FAILED" to="step4" />
    </batch:step>
    <batch:step id="step3" next="step3">
      <batch:tasklet ref="someTask1"/>
    </batch:step>
    <batch:step id="step4" next="step4">
      <batch:tasklet ref="someTask1"/>
    </batch:step>
  </batch:job>
  <batch:job id="job2">
    <batch:step id="failingStep">
      <batch:tasklet ref="failingTasklet"/>
    </batch:step>
  </batch:job>

  <bean id="step2Partitioner" class="org.springframework.batch.core.partition.support.MultiResourcePartitioner" scope="step">
    <property name="resources" value="file:${file.test.resources}/*" />
  </bean>

  <bean id="step2" class="org.springframework.batch.core.step.job.JobStep">
    <property name="job" ref="job2" />
    <property name="jobLauncher" ref="jobLauncher" />
    <property name="jobRepository" ref="jobRepository" />
  </bean>
</beans>
Run Code Online (Sandbox Code Playgroud)

Job1是我想要测试的工作.我真的只想测试step2.master到step3或step4的转换.我根本不想测试step1 ...

不过,我想继续作业1的规格不变,因为这个测试是测试的配置,而不是基本的操作.我已经有验收测试来测试端到端的东西.这个例子是这样我就可以写为小的变化的目标测试,而对于每条边的情况下创建单独的终端到终端的测试.

我要测试的是,当内部第二步作业失败,step2.master会将我第4步,而不是第3步.有没有对此进行测试的好办法?

java testing spring-batch

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×1

spring-batch ×1

testing ×1