0

We use spring batch in our java based application (financial banking application) and I'm looking for a good tool to test functionality including job level functionality using automation(also needs CI integration).

The goal is to run the batch jobs one by one and verify whether the functionality of the application is working correctly.

I want to know if anyone have used any tools which will help in that,both OS and paid ones.

Jithu Paul
  • 154
  • 2
  • 15

1 Answers1

0

We have multiple batch job in same project but as we follow TDD development we used to create JUnit test case for each job.

I am recommend to use JUnit4 for same , using JUnit and Jenkins CI I am sure you will achieve the goal you are looking for.

For enabling the Junit for your Spring batch you need to add below class as bean in your application org.springframework.batch.test.JobLauncherTestUtils

and need only code like this in JUint class

@Autowired
    private JobLauncherTestUtils jobLauncherTestUtils;


    @Test
    public void launchJob() throws Exception {
        // testing a job
        JobExecution jobExecution = jobLauncherTestUtils.launchJob();
     //Assert logic goes here

}

VishalTambe
  • 167
  • 2
  • 1
  • This type of a framework I have also made for my testing framework, we sue TestNG and Teamcity for CI and it works fine for me. My process also have a lot of jobs in it. – Jithu Paul Jul 25 '17 at 15:00
  • public void runJob(String jobCode) { Assert.hasText(jobCode, "A non-empty, non-null job code is required"); Long jobId = jobRunner.startJob(jobCode); try { jobRunner.waitForCompletion(jobId); } catch (TimeoutException e) { new RuntimeException(e); } } – Jithu Paul Jul 25 '17 at 15:00
  • @Autowired protected JobRunner jobRunner; – Jithu Paul Jul 25 '17 at 15:02