Search code examples
jobrunr

How do you set jobrunr in run now/eager mode for spring integration testing


I must be missing something obvious. I've got a couple of jobrunr jobs where i'm using the lambda enqueue format version 5.1.6. Like this:

JobId jobId = BackgroundJob.<MyService>enqueue(x -> x.doWork());

I would like to validate the plumbing and work in the jobs is executing via some integration tests with Spring, but don't see the options to run now, eager mode, etc? Thanks


Solution

  • You can't, I'm afraid.

    You can mock the JobScheduler and capture the args. JobRunr itself is also tested very well so if you pass a job, you can rest assured it will be enqueued.

    You could also put the pollIntervalInSeconds to 5 and use awaitility then to verify your job executed. There are many examples of this in the JobRunr repo.