Skip to content

Help with testing #1153

Answered by bensheldon
joshfester asked this question in Q&A
Nov 17, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Now that you're using ActiveJob, I would recommend that you do unit testing directly with Active Job's test adapter (which sidesteps GoodJob): https://edgeguides.rubyonrails.org/testing.html#testing-jobs-in-context

For integration testing, you can use GoodJob with :external execution mode, which will cause all jobs to go to the database. Something like:

ActiveJob::Base.queue_adapter = GoodJob::Adapter.new(execution_mode: :external)

MyJob.perform_later

assert_equal 1, GoodJob::Job.where(job_class: "MyJob").count # this is an Active Record model / scope chain

GoodJob.perform_inline

assert_results

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@joshfester
Comment options

Answer selected by joshfester
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants