title: Test individual Spring Batch Tasklet step with parameters
body: <p>I've implemented a simple job with 2 tasklets. I want to test the second tasklet by passing parameters. </p>
  
  <p>I've read the Spring batch documentation and below my test:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  @ActiveProfiles({"test"})
  @TestExecutionListeners( { DependencyInjectionTestExecutionListener.class,
          StepScopeTestExecutionListener.class })
  public class EtudeBatchApplicationTests {
      @Autowired
      private JobLauncherTestUtils jobLauncherTestUtils;
  
      public StepExecution getStepExecution() {
          StepExecution execution = MetaDataInstanceFactory.createStepExecution();
          execution.getJobExecution().getExecutionContext().putString("myValue", "foo,bar,spam");
          return execution;
      }
  
      @Test
      public void contextLoads() {
  
          JobExecution jobExecution = jobLauncherTestUtils.launchStep("insertIncludedSiretsStep");
      }
  
  }
  </code></pre>
  
  <p>My problem is in my tasklet, the myValue is always null.</p>
  
  <p>Below, the code of the tasklet:</p>
  
  <pre><code>@Component
  @StepScope
  @Slf4j
  public class InsertIncludedSiretsTask implements Tasklet {
      @Override
      public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
          Object myValue = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().get("myValue");
  
          log.info("INSERTINCLUDEDSIRETSTASK runnning");
          Thread.sleep(3000);
          return RepeatStatus.FINISHED;
  
      }
  }
  </code></pre>