concept JobLauncherTestUtils in category spring

appears as: JobLauncherTestUtils, JobLauncherTestUtils
Spring Batch in Action

This is an excerpt from Manning's book Spring Batch in Action.

We finish this chapter with The Big One: testing an entire job—an easy task with all that we’ve learned. With the help of the Spring TestContext framework and the JobLauncherTestUtils class, it takes only a few lines of code to do the job, as demonstrated in the following listing.

Listing 14.19. Testing a whole job

You start with Spring injecting a JobLauncherTestUtils , then call launchJob , and check the batch status. Finally, you count product table rows, and that’s all! You have successfully tested a whole batch job!

14.4.1. Introducing JobLauncherTestUtils

The JobLauncherTestUtils class is another class from the Spring Batch Test module to help you test a single Step or Job. The JobLauncherTestUtils class automatically injects a job by type from the application context; this implies that there’s only one batch job in your test application context. This is a best practice. With JobLauncherTestUtils, you can launch a single step of a job by specifying the step name. You can also specify job parameters. The following snippet shows how to launch only one step:

sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest