複雑なバッチアプリケーションがあり、フローに関する私の仮定が正しいことをテストしたいと思います。
これが私が取り組んでいるもののはるかに単純化されたバージョンです:
<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>
Job1は私がテストしたい仕事です。私は本当にstep2.masterからstep3またはstep4への移行をテストしたいだけです。step1をまったくテストしたくない...
ただし、このテストは基本的なアクションではなく構成をテストしているため、Job1の仕様はそのままにしておきたいと思います。私はすでにエンドツーエンドのものをテストするための受け入れテストを持っています。この例は、エッジケースごとに個別のエンドツーエンドのテストを作成せずに、小さなバリエーションのターゲットテストを作成できるようにするためのものです。
私がテストしたいのは、step2内のジョブが失敗した場合、step2.masterがステップ3ではなくステップ4に転送することです。これをテストする良い方法はありますか?