springspring-bootspring-batchspring-batch-adminspring-batch-tasklet

Set job name in Spring Batch Test


I am working on Spring Batch Unit test and every time I run my test-case I am getting job name as "TestJob". Is it possible to set/alter this and provide a new job name?

I tried and worked around:

jobLauncherTestUtils.setJob()

but could find anything helpful.


Solution

  • It seems you are launching a single step in isolation. In this case, a surrounding job named "TestJob" is created to wrap the step under test, see How is job name getting assigned in spring batch junit. It see no obvious way to change it.

    But in my opinion, when testing a single step in isolation, the surrounding job name should not really matter.