Skip to content

Add before and after queue hooks#46

Merged
ArturT merged 6 commits intomasterfrom
queue-hooks
Aug 12, 2017
Merged

Add before and after queue hooks#46
ArturT merged 6 commits intomasterfrom
queue-hooks

Conversation

@ArturT
Copy link
Copy Markdown
Member

@ArturT ArturT commented Aug 11, 2017

Add a way to defined before queue hook and after queue hook in Knapsack Pro Queue Mode.

# spec_helper.rb or rails_helper.rb

KnapsackPro::Hooks::Queue.before_queue do |queue_id|
  # This will be called only once before the tests started on the CI node.
  # It will be run inside of the RSpec before(:suite) block only once.
  # It means you will have access to whatever RSpec provides in the context of the before(:suite) block.
end

KnapsackPro::Hooks::Queue.after_queue do |queue_id|
  # This will be called only once after test suite is completed.
  # Note this hook won't be called inside of RSpec after(:suite) block because
  # we are not able to determine which after(:suite) block will be called as the last one
  # due to the fact the Knapsack Pro Queue Mode allocates tests in dynamic way.
end

Context:

  • The before queue hook is run in context of the RSpec.before(:suite) so you have access to whatever method RSpec provides.
  • The after queue hook is run outside of RSpec.after(:suite) context due to the fact we know when the queue is ended only when all tests fetched from Knapsack Pro API are executed hence we are not able to define RSpec.after(:suite) before the last run of a subset of tests from the work queue because we don't know which subset will be the last one.

Here is related PR with after subset queue hook: #41

Here is monkey patch fix done by Joel that was inspiration to add hooks https://gist.github.com/jturkel/20d12d47ad4cf3e8e111ff318dd5a09a

@ArturT ArturT changed the title Before and After Queue hooks Add before and after queue hooks Aug 11, 2017
@ArturT ArturT merged commit 52bbf9f into master Aug 12, 2017
@ArturT ArturT deleted the queue-hooks branch August 12, 2017 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant