New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a section about job testing #17476
Conversation
------------ | ||
|
||
Since your custom jobs can be queued at different levels inside your application | ||
(e.g. inside your models or controllers), you'll need to test both jobs themselves |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "different levels inside your application" is enough, we don't need the examples.
@sgrif : Updated ; thanks for the review ! :-) |
| -------------------------------------- | ------- | | ||
| `assert_enqueued_jobs(number)` | Asserts that the number of enqueued jobs matches the given number. | | ||
| `assert_performed_jobs(number)` | Asserts that the number of performed jobs matches the given number. | | ||
| `assert_no_enqueued_jobs { ... }` | Asserts that no jobs have been enqueued within the block. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with assert_no_performed_jobs
and because passing a block is optional, should we rewrite the purpose as Asserts that no jobs have been enqueued
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, good catch ! 👍
* Cover lower level job testing (assertions about the execution of the job itself). * Add a table with the custom assertions provided by Active Job's `TestHelper` module. * Add an example testing job queuing inside a model
@robin850 since you are on the issues team, I'll assign this back to you. You can solicit feedback directly from those who might be able to help you and merge this when it's ready |
Add a section about job testing [ci skip]
Thanks you very much everyone ! ❤️ |
Hello,
This pull request is just a follow up to #16921 addressing the different comments. This part makes the distinction between normal job testing and asserting that a job get enqueued/performed inside other components like models.
Also it makes the assumption that
ActiveJob::TestHelper
's methods are available directly fromActiveSupport::TestCase
as it should normally be the case (c.f. #17475).Cross-refs #16576.
Have a nice day.