title: How to test Spring Batch step without running entire job
body: <p>I am working on a Spring Batch application that has two steps in a job. I am trying to test each step individually. According to Spring documentation, I should be able to do so using <code>JobLauncherTestUitls.launchStep()</code>
  I have the following test set up for one of the steps</p>
  <pre><code>@SpringBootTest
  @SpringBatchTest
  @EnableAutoConfiguration
  @ContextConfiguration(classes = {JobConfig.class, EmailAndArchiveStepConfig.class, UpdateFactorReserveConfig.class})
  @ExtendWith(SpringExtension.class)
  @ActiveProfiles(&quot;test&quot;)
  class ConfigTest {
  
      @Autowired
      private JobLauncherTestUtils jobLauncherTestUtils;
  
      private JdbcTemplate jdbcTemplate;
  
      @Autowired
      public void setDataSource(DataSource dataSource) {
          this.jdbcTemplate = new JdbcTemplate(dataSource);
      }
  
      @Test
      @DisplayName(&quot;Testing Email and Archive Configured&quot;)
      public void testEmailAndArchiveConfig(){
          JobExecution jobExecution = jobLauncherTestUtils.launchStep(&quot;Email and Archive&quot;, executionContext);
  
          assertEquals(new ExitStatus(&quot;COMPLETED&quot;).getExitCode() ,jobExecution.getExitStatus().getExitCode());
      }
  </code></pre>
  <p>However, when I run this test, it starts the job from the beginning, running the other step as well, rather than just running this step that I want to test. I have not been able to find any solution to this.</p>