miguellima's avatar

What is the best way to test a job?

Hi everyone,

So my application relies a lot on jobs to do the heavy leafting, and I need to ensure that they do, what they suppose to do.

I don't just to assertDispatched, I need to ensure they are working.

I'm using batched jobs, jobs that dispatch other jobs.

What it best way to accomplish it?

Thanks!

0 likes
1 reply
jlrdw's avatar

When testing you can assert that it works, even if a test passed, real job could fail.

Run the jobs and make sure they really work in real life.

Normally when I test I'm looking for ways to refactor, not if something really works on actual production.

Just my thoughts on it.

Just a FYI, I've seen several questions where the person's real method would work, but they can't get a test to pass.

Of course see examples here: https://laravel.com/docs/9.x/mocking#bus-fake

Please or to participate in this conversation.