I'm having an application where i'm using spring batch. I want to write a test case which can test the batch job end to end. I have been exploring various options for the same. I checked if concordion test cases can be useful but i'm not sure if it's ideal way to test spring-batch jobs. So far i think integration test case should fit the best to my case. I would like to know what should be the ideal approach to test my scenario.
<batch:job id="batch-job">
<batch:step id="cleanupData" next="populateExchRates">
<batch:tasklet ref="dataCleanupTasklet" />
</batch:step>
<batch:step id="populateExchRates" next="populateCache">
<batch:tasklet ref="populateExchRatesDBTasklet" />
</batch:step>
<batch:step id="populateCache" next="ExternalDbQuery">
<batch:tasklet ref="populateFxRatesCacheTasklet" />
</batch:step>
<batch:step id="ExternalDbQuery" next="...">
<batch:tasklet ref="ExternalDBQueryTasklet" />
</batch:step>
...
</batch:job>
We have batch job defined as above, there are more than 20 steps which includes interface with external systems(>5 such steps), there are step readers etc.
While developing Integration test cases i was considering using spring-batch-test API along with Mockito so that I can mock steps involving external systems calls. Using this approach i'll have to create the mock objects in the spring configuration itself(Injecting Mockito mocks into a Spring bean). What i'm not sure about is how i'll mock the method calls for the mocked beans if i configure them using spring as below.
<bean id="dao" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="com.package.Dao" />
</bean>
I'm not sure if i could explain my scenario clearly or not. Please suggest if you have any other better opinion for testing E2E flow for spring-batch job and also if you can provide any clarity on the above approach that would be helpful.