Announcement Announcement Module
Collapse
No announcement yet.
unit test step - how to set up the execution context parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • unit test step - how to set up the execution context parameters

    Hi,

    I would like to create a unit test for a single step in a job. This step retreives some parameters from the ExecutionContext which have been put there by a ExecutionContextPromotionListener from the previous step ( I believe that this is the recommended method to pass variables to future steps )

    Is it possible to use the AbstractJobTests.launchStep() method to do this ? How can I get the variable into the ExecutionContext before launching the step?

    Thanks in advance !

  • #2
    I've created an issue to add this as a feature: http://jira.springframework.org/browse/BATCH-1295

    As a workaround, you could put a special job into your application context that contains only the step you want to test. Then you could wire into that job a listener with a BeforeJob method. The BeforeJob could load any necessary values into the Job's ExecutionContext. Your test could then launch this single-step job.

    Comment


    • #3
      I did this originally but then realised that I only want to test the batch jobs in my actual application as any test jobs would be slightly different and this is not really a useful test in my opinion.

      I have gotten around this problem by creating 2 xml files. One contains the batch job description and the other contains the beans. Then in the test case I override some of the beans with mock objects by including a third xml in the unit test context configuration. This allows a step to run using mock objects and placing variables into the execution context which can be then used by another step.

      Essentially I am testing different steps in the batch job by just mocking up certain steps.

      However I still think it would be useful to have this feature thanks a lot !

      Comment

      Working...
      X