Skip to content

Instantly share code, notes, and snippets.

@konk303 konk303/test-queue.rb
Last active Jul 6, 2017

Embed
What would you like to do?
Simplified test-queue runner with simplecov
#!/usr/bin/env ruby
require 'test_queue'
require 'test_queue/runner/rspec'
class MyAppTestRunner < TestQueue::Runner::RSpec
def after_fork(num)
SimpleCov.command_name "worker#{num}"
ActiveRecord::Base.configurations['test']['database'] << num.to_s
ActiveRecord::Base.establish_connection(:test)
end
# initialize
def prepare(concurrency)
1.upto(concurrency) do |i|
ActiveRecord::Tasks::DatabaseTasks.drop_current
ActiveRecord::Tasks::DatabaseTasks.create_current
ActiveRecord::Tasks::DatabaseTasks.load_schema_current
# master doesn't need connection
ActiveRecord::Base.connection.disconnect!
end
end
def cleanup_worker
# record each worker's result
SimpleCov.result
end
def summarize
# output result
SimpleCov.at_exit.call
end
end
MyAppTestRunner.new.execute
@konk303

This comment has been minimized.

Copy link
Owner Author

commented Mar 30, 2016

then

SimpleCov.start do
  at_exit do
    SimpleCov.result.format!
  end
end

at the top of my spec_helper.rb creates whole result to html, when master is finished.

@konk303

This comment has been minimized.

Copy link
Owner Author

commented Apr 1, 2016

for some reason I had to define SimpleCov.at_exit outside of SimpleCov.start {} to make it defined as I wanted.

(I guess it's simplecov's matter, nothing to do with tmm1/test-queue#35 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.