0

I am testing spring batch job in junit.

public void testJob() {
    JobExecution jobExecution = jobLauncherTestUtils.launchStep("processFileStep", params2, executionContext);

    JobParameters params3 = new JobParameters(setJobParams());

    jobLauncherTestUtils.launchStep("downloadResultsFile", params3, executionContext);

    Collection<StepExecution> actualStepExecutions = jobExecution.getStepExecutions();

    assertThat(actualStepExecutions.size(), is(1));

    assertThat(jobExecution.getJobInstance().getJobName(), is("TestJob"));// where is it set to TestJob?
}

I dont understand how the job name is set to TestJob. ?Thanks for your time.

Namagiri Sridhar
  • 177
  • 1
  • 6
  • 18

1 Answers1

1

When you use the JobLauncherTestUtils to launch a step, Spring Batch will create a single-step job of type SimpleJob named TestJob surrounding your step and launch it. You can see this in the code here.

This does not seem to be documented, so I created an issue to improve the docs in that regard.

Mahmoud Ben Hassine
  • 28,519
  • 3
  • 32
  • 50